zsh-users
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Neat hash -d trick
Date: Fri, 22 Oct 2010 16:24:21 +0200	[thread overview]
Message-ID: <2303.1287757461@thecus> (raw)
In-Reply-To: <101021210513.ZM30802@torch.brasslantern.com>

Bart wrote:
> A similar trick:
  [snip]
> 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
list.
  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
    PREFIX="~$PREFIX"
    IPREFIX=${IPREFIX%\~}
  fi
  dirs=( ${(s./.)${~PREFIX:-$PWD}} )
  for f in $dirs; do
    dest+=${dest[-1]}/$f
  done
  PREFIX=
  compstate[list]=packed
  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.

Oliver
 


  parent reply	other threads:[~2010-10-22 14:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-21 22:34 Nikolai Weibull
2010-10-22  4:05 ` Bart Schaefer
2010-10-22  7:28   ` Mikael Magnusson
2010-10-22  8:09     ` Julien Nicoulaud
2010-10-22  8:39     ` Jérémie Roquet
2010-10-22 10:29   ` Nikolai Weibull
2010-10-22 14:24   ` Oliver Kiddle [this message]
2010-10-27 15:45 ` Jean-Rene David

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2303.1287757461@thecus \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).