Artificial intelligent assistant

Displaying ~ for $HOME in zsh prompt I have my prompt set to the following: PROMPT=%F{reset}[%F{blue}%2/%F{reset}] which displays two parent directories as [foo/bar] However, when I'm in `$HOME` or one directory deep in `$HOME`, I'd like the prompt to be displayed as [~] [~/foo] respectively, instead of [/Users/me] [me/foo] I've tried approaches like Steve Losh's `collapse_pwd` (and the simpler version: `${PWD/#$HOME/~}` also mentioned in the article) and other similar ones, but I lose the flexibility of being able to show only the last two directories. How can I modify the above to handle `$HOME`? My zsh version is `zsh 5.0.0 (x86_64-apple-darwin12.0.0)` on OS X 10.8.2

`zsh` has built-in support for that. Use `%2~` instead of `%2/`. See also `%40<...<%~`

See also the `autonamedirs` option:


$ l=/usr/local
$ PS1='%~$ '
~$ setopt autonamedirs
~$ cd /usr/local
~l$


(without `autonamedirs`, you can still do `cd ~l` to `cd` to `/usr/local` and your prompt to show `~l`).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 5f9fb3fb85d38a6410b46a6b2a32969e