Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Neat hash -d trick

Bart wrote:
> A similar trick:
> Now you can type ESC 4 . to insert ../../../.. (or ESC 9 ESC 9 . to
> insert 99 levels, if for some insane reason you need that many).

If you find counting the directories harder than doing it interactively
on the screen we could try using menu selection. This splits either the
path currently on the command-line or $PWD if that's empty into
directory components and then does menu selection with them in a packed
  zle -C up-dir reverse-menu-complete _generic
  zstyle ':completion:up-dir::::' completer _up-dir
  bindkey '^X\e[A' up-dir

And _up-dir contains:
  #compdef -k reverse-menu-complete ^X\e[A

  local -a dirs
  local -a dest
  compset -P '*[=:]'
  compset -S ':*'
  if [[ $compstate[context] = tilde ]]; then
  dirs=( ${(s./.)${~PREFIX:-$PWD}} )
  for f in $dirs; do
  compadd -V dirs -d dirs -f -qS/ -a dest

I'm not sure if that's depending on further styles I have but you should
be able to get the idea. I can't remember how to make menu selection
really do reverse-menu-complete and give me the last completion to begin
with.  It clears off anything up to and equals or colon in the current
word and includes a hack for the tilde context. I was also trying to
remember if there was a way to separate the completion matches with a
slash instead of spaces but I don't think there is.


Messages sorted by: Reverse Date, Date, Thread, Author