Jun 6
From here come some interesting hints.
- In bash, type alt + ., or esc + . to append the last argument from the last command. Repeat to go back up the command stack. You can also use alt + 1 alt + . to get the first command, etc.
- Use du to summarize disk usage for directories only, via du -h –max-depth=1.
- Use readline to edit a command in an editor: ctrl-x ctrl-e. Make sure you set $EDITOR. Can also use fc (fix command) to do this for the last command.
- To create or wipe a file, use > filename. Compare: touch filename.
- Quickly look at ascii character codes with man ascii.
- Nice simple stopwatch with time read (then enter). Or for a countdown timer, read -t 5 for 5 seconds.
- Use pushd /path/to/dir instead of cd, then popd to get back.
- Use alt + b, alt + f to move forwards/ by a word. You can use numeric arguments as well.
- Kill a word backwards with ctrl + w, then ctrl + y to yank. Rotate kill ring with alt + y. Kill word forwards with alt + d.
- Kill backwards to the start of the line with ctrl + u.
- Use alt + t to transpose the last two words.
- alt + \ will remove all whitespace around the cursor.
A nice trick to copy your ssh key to a remote machine:
ssh remote-machine 'cat >> .ssh/authorized_keys' < .ssh/identity.pub
Tunnel ssh via an intermediate host, or otherwise use a pseudo-tty:
ssh -t reachable_host ssh unreachable_host