Dec 202010
More Efficient Bash Tips
Let’s make bash more efficient, useful and powerful.
Tips1:Ctrl-r
Using Ctrl-r, it’s a good tip for bash to operate history commands. When you want to find the commands history for your shell, some people use UP key, some people use $history with $grep. Another very good idea is Ctrl-r, just try it, you will find the shell from $ to ‘(reverse-i-search)`’:, you can type anything here, terminal will search your command history.
Tips2:Alt-.
What is Alt-.? Let’s think about this:
$mkdir /home/my/this/is/a/very/long/long/long/path $cd /home/my/this/is/a/very/long/long/long/path
Why we need to do this? let’s try the following command:
$mkdir /home/my/this/is/a/very/long/long/long/path $cd Alt-.
Aha, now you know, Alt-. get the parameters from the last command, you can use it directly.If there are many parameters, ok, let’s try:
$Alt-0 Alt-. $Alt-1 Alt-.
It’s very useful.
Tips3:Ctrl-p, Ctrl-n
It’s UP and DOWN key binding as Emacs key. Emacs users all like this.
Tips4:Ctrl-o
Ctrl-o? it’s not easy to say, it will execute the last command loop. you should try the following command:
$du -sh $Ctrl-o $Ctrl-o
If you have more tips, welcome to share.
