Zsh 5.0 released
github.com
github.com
Does this mean something like syntax highlighting for the command line is now possible?
It's pretty great as a starting point, but it really could use more people writing highlighter plugins for different things. It's on my list of things to figure out how to do eventually.
Fish is another shell that supports syntax highlighting out of the box.
Currently I'm thinking about the Fish-style syntax highlighting. Fish is really nice, but it's not very compatible with the rest of the shell environment. So I'm back on Bash, but really miss the syntax highlighting. I need some good reasons to switch again...
Ctrl+R in bash (by default, at least) will not search from the middle of a command. For instance, if the previous command was "hello", searching for "ello" will not bring it up. Whereas with zsh, it will.
> ell<TAB>
Completing external command
git-shell xdmshell xkbbell
Completing shell function
_ispellAnd, there's even a script that offers Fish-like syntax coloring for Zsh: https://github.com/zsh-users/zsh-syntax-highlighting/
But not having used Fish yet myself, I can't really offer any reasons to use Zsh over Fish.
Bash script compatibility, bigger userbase and therefore more third party customizations.
Fish's consistent syntax for conditionals/loops is what brought me over in the first place, I always needed to work to remember what goes where in zsh/bash. For one-off tasks the reduction in mental overhead was a _huge_ win.
That said, I recently did switch back to zsh for a functional command-not-found handler - fish's only includes the name of the binary rather than the whole command, so I couldn't productively use it as a retry wrapper.
Thing is there's no real feature I've noticed that made me think "Wow! How did I live without this?". Yeah I see some nice things but they feel like party tricks rather than game changing features.
I dunno, maybe I'm not seeing the big picture here. Is there anything out there that'll show what amazing things that zsh can do? Like is there anything out there that could make me stop using it like bash?
The glob features are certainly quite useful too, for example, if there's a file nested deep inside some directory I can just enter
vim **/filename
and zsh will expand it for me.- Keyboard navigation for TAB completion (using the arrows)
- Coloured TAB completion
- "for" one-liners: for f in /*.py; wc -l $f
- Named directories (cd ~named_dir)
(edit: formatting)
for f in *.py; do wc -l $f; done
also, you can do something like
for f in `find project_name`; do wc -l $f; done t work on the output of another command.
Cheers!
I've currently got a three line prompt that includes info about my current repository: (git)[45afc8f02fef U master [origin/master ] ]
It lists type (git/hg) [checkout (U)pdated branch [remote branch] ]. It'll tell you how many branches different the remote is, what you are up to (staged), and colors.
That, better tab completion, and syntax highlighting of the command line are my killer features. I'm running a fork of the oh-my-zsh project, so you can see the features by grabbing a copy: https://github.com/srathbun/oh-my-zsh
Don't worry about learning all the benefits at once. Make your shell look exactly like what you've got now and figure out the new features as you go along. There'll always be something new to make you smile.
But MY favorite feature of zsh is ZLE: the Zsh Line Editor. The fact that I hit up-arrow, and see the for|while|if statements as I typed them, rather than mashed together into a horrible, semi-colon infected, one-liner (like bash) is awesome.
I commonly write long for loops in the shell and hitting the up arrow to bring it back up, should I want to edit it, etc., then it appears with all the newlines just as I typed it.
Does this mean I have to manually enter the path like /usr/local/zsh?
It's annoying when you're trying to see where/when a fix has been landed.
Commit on the official repository: http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=co...
In my plain gnome-terminal with git it would instantly autocomplete when I pressed tab.
I have a few patches that speed up its git plugin by letting you opt-out of expensive operations. https://github.com/davvid/oh-my-zsh/commits/davvid
Last I checked, oh-my-zsh was in transition to a new version(?), and the pull requests have generally been ignored because of this.
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
which lets it avoid expensive checks that my prompt doesn't need (it already shows that info elsewhere).The real big win is that I export `POST_1_7_2_GIT=1` in `~/.zshrc` and the tweaks I made teach the git plugin to use `--ignore-submodule=dirty` when calling `git status`, which makes a huge difference.
I haven't caught up with oh-my-zsh in a bit; if there's a good place for me to rebase onto and do a new pull request I will. Does anybody know who the real oh-my-zsh maintainer is these days?
Not using oh-my-zsh or the like, zsh has lots of hooks and omz uses a lot of this hooks for or around git repos, so CD-ing into a git repo entails loads of work.
Use vanilla zsh and configure as needed, and it'll be as zippy as everywhere else.