Skip to content

Instantly share code, notes, and snippets.

Created December 21, 2011 21:14
  • Star 24 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Why I love zsh (and hate being forced to use bash)

Why I love zsh (and hate being forced to use bash)

  • Smarter completion. A few examples:
  • context sensitive -- if you have file "name1" and directory "name2", "cd nam<TAB>" completes to "name2/"
  • "tar xf <TAB>" completes to tarballs only. "unrar x <TAB>" completes to RARs only. etc.
  • rsync / scp completion: "rsync host:anything/<TAB>" shows you files on host under anything/
  • also works with rsync:// URLs
  • SSH host completion from ~/.ssh/config & ~/.ssh/known_hosts
  • lots of other smart completions: Rake tasks, git commands & SHAs, dpkg packages, dash-options for most commands, etc etc.
  • bash can do some of the same things, but needs the bash-completion package, usually comes separately
  • zsh always comes with completions -- it's a user-oriented shell
  • Filename correction during completion
  • if dir1/x exists and dir2 exists, then "dir/x<TAB>" completes to dir1/x
  • if name1 is a file and name2 is a directory with files in it, "name/<TAB>" completes to "name2/"
  • Better ctrl-R behaviour
  • alerts you if your ctrl-R is failing
  • completes it right on the prompt line while showing you what you're searching for below
  • ctrl-R, enter a search term, ctrl-R repeatedly to see earlier matches, then hit backspace
  • bash deletes characters in your search term
  • zsh backtracks through the matches you rejected with ctrl-R, i.e. "backspaces" your ctrl-R's
  • autopushd option -- every "cd" is implicitly a silent "pushd" so you can "popd" to go back any time
  • better popd behaviour if a directory no longer exists
  • zsh will still pop the stack, so subsequent popd's work
  • bash refuses to popd
  • incremental history saving option
  • saves after every command
  • my .zsh_history is chronological and always up-to-date, even with multiple shells running
  • in any shell, I can "fc -R ~/.zsh_history" to reload in order to reuse the latest commands
  • optional coloured completion (like "ls")
  • autocd option -- "executing" a directory will "cd" to it instead
  • e.g. if I start typing /some/dir/file and decide I want to switch to /some/dir instead, I just enter "/some/dir"
  • `some-command`<TAB> -- expand output of some-command right in your shell line
  • can automatically show exit status of last command
  • always know when something failed, even if the output doesn't make it obvious
  • can automatically show "time" output if a command takes more than <n> seconds
  • usually has the latest UI improvements first
  • most of bash's features originally came from zsh
  • probably a lot more that I've forgotten
Copy link

Missed a big one, SCP and SSH completion. But I guess you can lump that together with custom completions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment