Difference between revisions of "ShellEnhancement"

From SME Server
(New page: ==Expand memory of you .bash_history== Expand the "memory of your .bash_history to 2000 lines adding this on your .bashrc: <pre> export HISTFILESIZE=2000 export HISTSIZE=2000 </pre> == Ea...)
 
m (Add a horizontal line above the category.)
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
==Expand memory of you .bash_history==
+
== Sort & Remove Duplicates ==
Expand the "memory of your .bash_history to 2000 lines adding this on your .bashrc:
+
This will sort and remove duplicate commands from your .bash_history file in the /root directory, as well as reducing the file size.
 +
After you execute the command below, you should edit the file and remove any commands or lines that have errors in them so they aren't
 +
executed accidentally.
 +
 
 +
<pre>
 +
sort -u /root/.bash_history -o /root/.bash_history
 +
</pre>
 +
 
 +
== Expand memory of your .bash_history ==
 +
Expand the memory of your .bash_history to 2000 lines adding these lines to your .bashrc:
 
<pre>
 
<pre>
 
export HISTFILESIZE=2000
 
export HISTFILESIZE=2000
 
export HISTSIZE=2000
 
export HISTSIZE=2000
 
</pre>
 
</pre>
 +
 +
== Add Date/time to each line in your .bash_history ==
 +
Add Date/time to each line in your history adding this line to your .bashrc:
 +
<pre>
 +
export HISTTIMEFORMAT='%F %T '
 +
</pre>
 +
Read 'date' man page to format date/time according to your needs
  
 
== Easy search using arrows ==
 
== Easy search using arrows ==
Create a .inputrc with :
+
Create a .inputrc, or edit your /etc/inputrc, with :
  
<pre>"\e[A": history-search-backward
+
<pre>
 +
"\e[A": history-search-backward
 
"\e[B": history-search-forward
 
"\e[B": history-search-forward
 
</pre>
 
</pre>
  
 
Next logon you'll be able to search command by start to write them and use up/down arrows.
 
Next logon you'll be able to search command by start to write them and use up/down arrows.
 +
 +
<pre>
 +
"\e[1;5A": history-search-backward
 +
"\e[1;5B": history-search-forward
 +
</pre>
 +
 +
Will allow you to use ctrl+up/down arrows (and your up/down arrows will work as usual).
 +
----
 +
<noinclude>[[Category:Howto]]</noinclude>

Latest revision as of 20:42, 20 September 2009

Sort & Remove Duplicates

This will sort and remove duplicate commands from your .bash_history file in the /root directory, as well as reducing the file size. After you execute the command below, you should edit the file and remove any commands or lines that have errors in them so they aren't executed accidentally.

sort -u /root/.bash_history -o /root/.bash_history

Expand memory of your .bash_history

Expand the memory of your .bash_history to 2000 lines adding these lines to your .bashrc:

export HISTFILESIZE=2000
export HISTSIZE=2000

Add Date/time to each line in your .bash_history

Add Date/time to each line in your history adding this line to your .bashrc:

export HISTTIMEFORMAT='%F %T '

Read 'date' man page to format date/time according to your needs

Easy search using arrows

Create a .inputrc, or edit your /etc/inputrc, with :

"\e[A": history-search-backward
"\e[B": history-search-forward

Next logon you'll be able to search command by start to write them and use up/down arrows.

"\e[1;5A": history-search-backward
"\e[1;5B": history-search-forward

Will allow you to use ctrl+up/down arrows (and your up/down arrows will work as usual).