zsh seems to be getting a lot of press of late …
by Mez on Dec.17, 2008, under Personal
And so it should – it’s an awesome shell.
Anyway, I’ve just spent a lot of time sorting out my zsh so it does titles in the right way. By this, I mean changing the title of your xterm window, and/or your screen window.
Anyway, here’s the code that I use for my zsh titles
precmd () {
case $TERM in
screen)
print -Pn "\e]0;%n@%m: %~\a"
print -Pn "\ekzsh: %~\e\\"
;;
xterm*|rxvt)
print -Pn "\e]0;%n@%m: %~\a"
;;
esac
}
preexec () {
case $TERM in
screen)
print -Pn "\e]0;%n@%m: $1\a"
print -Pn "\ek$1\e\\"
;;
xterm*|rxvt)
print -Pn "\e]0;%n@%m: $1\a"
;;
esac
}
I find this works in the same way that the default bash shell does
though – it also works quite nicely with screen, and sets the screen titles for you too
Also – my prompt lines are (inspired by Daniel Silverstone circa 2005)
export RPROMPT='%B%d%b %t ' export PROMPT='%B%n@%m %#%b '
Happy zsh’ing folks!

December 17th, 2008 on 5:49 am
Hi Martin!
Thanks for the cool blog post! I’ve been using zsh for a long time and I’m absolutely in love with it. I tried your functions and they are really nice! =:) One thing, though…. I use the prompt built-in for my zsh shell theme (autoload promptinit; promptinit; prompt fade green) and I think it does something with precmd and preexec too, so your functions and those done by prompt were conflicting (one or the other wasn’t getting executed. Anyway, I think i’ve found a way around it. $(man zshall) shows that zsh actually allows an array of function names for precmd and preexec. So I’ve changed your function names to myprecmd and mypreexec and then declared arrays so that zsh calls my precmd/preexec as well as whatever else declares these. What I have looks like this:
Anyway, thanks again for the great blog post! Zsh rocks!! =:)
December 17th, 2008 on 9:18 am
While ZSH is getting a lot of press, I find it worth checking out the Fish shell, which is powerful and yet easy to use:
http://www.fishshell.org/
http://arstechnica.com/articles/columns/linux/linux-20051218.ars/2
December 17th, 2008 on 3:35 pm
Jason:- thanks for the tip
Mark:- I’ll have a look at it sometime
December 17th, 2008 on 5:26 pm
I’d like to offer a +1 for the Fish shell. This baby’s the best shell I’ve ever used, even though it took a little bit of getting used to due to my embedded bashisms.
I’ve been using http://github.com/zmalltalker/fish-nuggets/tree/master for some more goodness including marking the current branch when you are in a git repository directory and such.
December 17th, 2008 on 6:38 pm
zsh? fish? Use rc, the shell whose grammar you can understand!
December 18th, 2008 on 9:21 pm
This code looks familiar.
December 19th, 2008 on 8:19 am
jpds – I wrote it myself