Here are some shell/term tips I use on a day to day basis.
When typing a command, using esc-.
inserts the last argument of the previous command.
$ ls aaa.txt bbb.txt ccc.txt
...
$ ls <esc-.>
$ ls ccc.txt
You can even type esc-.
several times and go back from command to command.
$ ls aaa.txt
$ ls bbb.txt
$ ls ccc.txt
...
$ ls <esc-.>
$ ls ccc.txt<esc-.>
$ ls bbb.txt<esc-.>
$ ls aaa.txt
If you need to use the output of a command as file you can use <(command)
. Let's say we have a command that needs a file and does not take standard input.
$ some_command some_file.txt
We would like to pass it the output of ls
. We can put the output of ls
in a file and then pass that file to some_command
but sometimes it's not very practical to do so. Using <(...)
can save the day.
$ some_command <(ls)
You can even do a diff of two command outputs that way.
$ diff <(ls -1 /some/directory) <(ls -1 /some/other/directory)
Using cd -
you can go back to the previous directory.
~/somewhere $ cd ~/somewhere-else
~/somewhere-else $ cd -
~/somewhere $ cd -
~/somewhere-else $
Sometimes a SSH session can freeze and nothing more can be done, except... there is. Use ↵~.
(enter, tilde, dot) to kill the frozen session.