Skip to content
Create a gist now

Instantly share code, notes, and snippets.

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

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

  • Smarter completion:
    • cd tab completion -- directories only
    • bash can do this, but needs the bash-completion package, usually comes separately
    • zsh always comes with completions, why doesn't bash?
  • 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

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
Something went wrong with that request. Please try again.