I like Zsh. It's a powerful, efficient shell. It's better than Bash by just about every metric (better performance, more features, better sh compatibility). I really have no idea why people keep using Bash.
Anyway, I put together a little piece of zshrc
to show my
current status in right-hand prompt - a prompt that's shown
right-aligned in the shell. Zsh has a couple of features that make this
really easy.
First the prompt_subst
options instructs the shell to do
variable substitution when evaluating prompts. So if you were to set
your prompt to '$PWD> '
then your prompt would contain
your current directory. Of course you wouldn't do it that way,
%~
does that much more nicely, but that takes us to Zsh's
second feature,
ridiculously powerful variable substitution and expansion. In my prompt I just use the simple
$(shell-command)
substitution, but there's a full
complement of file-io, string manipulation and more to be had.
https://gist.github.com/ianloic/1046832#file-git-prompt-zsh