This is a nice doc that explains the features that zsh brings to the table over and above the more standard choices such as bash:
Some goodies of particular interest to me:
- An expression of the form
matches a range of integers: % ls run<200-300>
- Giving directories short names in the prompt:
~inews> namedir () { $1=$PWD ; : ~$1 } ~inews> cd /usr/princeton/bin /usr/princeton/bin> namedir pbin ~pbin> cd /var/spool/mail /var/spool/mail> namedir spool ~spool> cd .msgs ~spool/.msgs> - A command name with a = prepended is replaced with its full pathname.
% ls -l `which rn` -rwxr-xr-x 1 root 172032 Mar 6 18:40 /usr/princeton/bin/rn % ls -l =rn -rwxr-xr-x 1 root 172032 Mar 6 18:40 /usr/princeton/bin/rn
- Using process substitution, you can edit the output of a command:
% ed =(who | fgrep -f ~/.friends)
- Most other shells have aliases of this kind (command aliases). However, zsh also has global aliases, which are substituted anywhere on a line. Global aliases can be used to abbreviate frequently-typed usernames, hostnames, etc:
% alias -g PASS='<(ypcat passwd)' % grep pfalstad PASS pfalstad:*:3564:35:Paul John Falstad:/u/pfalstad:/usr/princeton/bin/zsh
- A variant of the fc command is r, which redoes the last command, with optional changes:
% echo foo foo % r foo=bar echo bar bar
- ESC Q = put line on buffer stack
- ESC H = put line on buffer stack and run man with current command
- ESC A = execute current line and retain in buffer
- ESC ' = quote current command line.
- An easy way to change your path is to use the vared command:
% vared PATH > /u/pfalstad/scr:/u/pfalstad/bin/sun4:/u/maruchck/scr:/u/subbarao/bin:/u/maruc hck/bin:/u/subbarao/scripts:/usr/princeton/bin:/usr/ucb:/usr/bin:/bin:/usr/host s:/usr/princeton/bin/X11:/./usr/lang:/./usr/etc:/./etc
You can now edit the path. When you press return, the contents of the edit buffer will be assigned to PATH
- Using the AUTOCD option, you can simply type the name of a directory, and it will become the current directory.
% setopt cdablevars % foo=/tmp % cd foo /tmp

Testing that comments work. You guys have been quiet lately 🙂
I’ve been convinced. zsh has caught my attention and bash may be on its way out for me. 🙂