escape code

zsh: learn while doing

joepd, 17 April 2014

What good are advanced and hard to remember features if there is no help available at a fingertip? Globbing in zsh might be the best thing since sliced bread, but if you don't know the details, you might as well be chewing on a brick.

So, why not organize in such a way so that the details are readily available? One of the many nice ideas from feh's excellent zsh configuration file does exactly that, but it looked ugly on a too small terminal, and it looks like quite some manual work to format the information in ~/.zshrc. So I made zsh-hints, a small helper program that turns a definition file into helpful hints.

Who can remember all those glob flags? Imagine wanting to see the Setgid, and world readable files in somewhere here in a subdirectory. Just hit <CTRL X><g>

% print -l **/*<CTRL X><g>

… and you will be presented with this result:

% print -l **/*
/           ▶ directories
F           ▶ non-empty directories (full)
.           ▶ plain files
-           ▶ executable plain files
l[-+]n      ▶ link count
r,w,x       ▶ owner (r)eadable (w)ritable,
              e(x)ecutable files
A,I,E       ▶ group re(A)dable wr(I)table,
              (E)xecutable files
R,W,X       ▶ world (R)readable, (W)ritable,
              e(X)ecutable files
s,G,t       ▶ setuid, setgid, sticky bit files
f[+=-]NNN   ▶ files with access rights matching
              +,-,= octal number
{U,G}NNN    ▶ owned by effective (U)ser,(G)roup
              ID
{u,g}NNN    ▶ owned by user, group id `NNN`
{u,g}:name: ▶ owned by user, group name `name`
   ...18 hints omitted.

A quick glance will help you conclude that (.GW) is what you are looking for.

This example was made on a rather small terminal. That is why some of the explanations were wrapped, and were displayed with a secondary separator of just a space. It also did not fit in the vertical direction. An optional message notifying how much you are missing on is displayed.

The key file is really simple to make: It just assumes that the first space separates the key from the explanation. There is no way of putting a space in the key.

All the details of installation and configuration are covered in the README. Please let me know if it does or does not work for you.

Enjoy :)