GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Tuesday 14 January 2003
A few zsh functions -- mini-manpages

Here are brief, less-than-man-page style descriptions of a few of the small shell functions that I use. Most of the implementations are obvious, but I'll put them up here in a few days, after I've ported my cygwin zsh _z* shell file/functions back to Mac OS X and Solaris.

  • addpath, rmpath — add or remove a directory from the $path array (which, in zsh, is tied to the colon-separated $PATH env var)

  • nd — name the current directory (sets a zsh variable to $1 (or defaults the var name to the cur dir's leaf name)). The value of this one is best seen when you have the zsh option autonamedirs set, and a %~ somewhere in your prompt. Your new short name will show up in the prompt where the %~ is, instead of the longer path that it probably took to get there. This was a great help at Apple, where excruciatingly long pathnames are all over the place.

  • dh and the z family — "z" is my cd command. It is always a "pushdir", keeping track of what directories you've been in. To replace the useless, all-on-one-line display that csh used to do, zsh's "dirs -v" command lists the directories, tilde-abbreviated. Unfortunately, it lists them with the most recent ones at the top, so that they'll scroll off if you have a lot of them. "dh" just does a "sort -nr" on that output, so that the most recent are at the bottom.

    Bonus: the numbers that zsh lists along with the dir. stack can be used as shorthands, as in ~3.

    The "z" family of cd-related commands have a few that are just directory shortcuts (zh, zt, zb to go to my sub-home directory $h, my top-level $t, and my bin directory $b), but the ones I use the most often are

    • zl — go there and then ls

    • zf — strip the last component (:h) and then cd. This is most useful when you've dragged a file into your shell, if you typed "zf " first, then drag a file, then hit return, you don't need to mess around with removing the filename part — zf does that for you.

    • zq pattern — go back to the last dir in the stack that matches the given pattern.

9:52:35 AM   comment/     


Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/2/6; 12:28:08 .
Click here to send an email to the editor of this weblog.

January 2003
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Dec   Feb

Previous/Next