This Post is very special to the bash lovers,which also includes me .I’m trying to put very special commands i use normally,at a place.So here I go:
1.Past commands:
Press ctrl+r when the terminal is opened and you can get the past commands entered recently,matched with your letter.
This method is far better than pressing up key like a mad donkey.
Ex: press ctrl+r at bash prompt ull get sumthing like (reverse-i-search)`’: ,
now if u want ln -s /home/kranny/firefox/firefox ./firefox to be run,just type ln,and it will find u the command if it is typed recently….
2.My most fav:
Pressing Esc brings up the last object you referred to.If you had just typed cat /etc/apt/sources.list , then typing gedit then pressing esc . would auto complete to gedit /etc/apt/sources.list.i jus luv this…
3.Spelling Mistakes are annoying me:
Many times i type clera for clear and the msg “command not foun” annoys me….Just add the foll lines to ur .bashrc:
shopt -s cdspell
and spelling mistakes are ignored
4.werz my history?
When u type some commands ina terminal and Btw open a new terminal, the new one won’t remember any of the commands typed in the first one and moreover closing the first terminal, and then the second will overwrite any of the commands typed in the first terminal.Again this annoys!!!!The reason for this is that the bash history is only saved when you close the terminal, not after each command.Just add these lines to bashrc
shopt -s histappend
PROMPT_COMMAND=’history -a’
This makes bash append history instead of overwriting it, and makes it so that each time the prompt is shown it writes out all the history.
5.curly brackets {}:
I use this most of the times.If u want to make a copy of any files in the same/diff dir whose path is quite lengthy
Ex:cp /var/cache/apt/archives/aa.conf /var/cache/apt/archives/aa.conf_backup
can be replaced with cp /var/cache/apt/archives/aa.conf{,_backup}
PS 1:if u have any comment me,if they are worth using,ill update the post
I use bash also as calc:
echo $((2+2))
or
echo 2+2 | bc
That’s useful for bash scripting too
Its a wonderful post ,i must say…this is a Nice Place to be around..
Gr8 Post…thanks
Nice Collection of tips
Thanks a lot
Second tip is really Beautiful…Thanks