Zsh Cheatsheet

(excuse the crappy layout, this is a draft)

  • tab is completion programmable and can dependent on the command it is used with. examples:
    • cd<TAB> shows a list containing only directories
    • cd -<TAB> shows you a list of recently visited directory, select with cursor where to go. instead of pressing <TAB>, you could also have typed cd -2 to go to the 2nd last dir.
    • ssh<TAB> shows a list of all known hosts
    • kill<TAB> gives you a list of processes. another example: `kill memca` finds the correct pid and inserts it
  • cd-less directory switching (just type name of directory)
  • all shell windows share one history, i.e you can access a command from window A’s history in a new window B
  • can shorten the path shown in the prompt (“Resources/Styles/Marble $” instead of ”/Applications/Chess.app/Contents/Resources/Styles/Marble $”)
  • more powerful globbing. example: ‘ls \\*/\_helper.rb’ lists all *_helper.rb files in the current tree
  • temporary aliases for directories, using ~dirname:
~ $ work=`pwd` 
~ $ cd / 
/ $ cd ~work ~ 
$ pwd /Users/phillip
  • bash-compatibility
  • optional prompt at the right top side
  • multiline commands with quoted strings
> sci -m "Bla
dquote> bla bla" 
  • remote path completion
scp xe<TAB>app1:/vir<TAB>tual
  • multi-line commands are editable
for x in 1 2 4
  echo $x
  • correct last command
  • directory stacks and -history
cd -<TAB>
  • smarter Ctrl-R search in command history

General shell tips

  • Ctrl-K: Kill text to end of line (not specific)
  • use !$ and !!
  • use history