From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] expand '..n' to equivalent number of '..' segments in fixdir
Date: Sun, 10 May 2020 14:21:36 +0000 [thread overview]
Message-ID: <20200510142136.282ecedb@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <01329055-ca28-e00f-0fd2-34c619371fbb@gmx.com>
Eric Cook wrote on Sun, 10 May 2020 03:09 -0400:
> On 5/10/20 3:06 AM, Eric Cook wrote:
> > I personally think a wrapper function is more appropriate.
>
> One not distributed with zsh itself that is.
Or a shell widget, like Mikael's rationalise-dot widget that lets one
type «cd ...» to get «cd ../..» and so on. This also has the benefit
of not requiring completion functions to be taught about the new syntax.
I don't have his latest version handy, but I use a modified version:
_rationalise-dot2 ()
{
if [[ $LBUFFER == *( ) ]]
then
zle .self-insert
return
fi
local -a tokens; tokens=(${(z)LBUFFER})
if [[ $tokens[-1] == (../|*/../) ]]
then
LBUFFER+=../
elif [[ $tokens[-1] == '.' ]]
then
LBUFFER+=./
else
zle .self-insert
fi
}
zle -N _rationalise-dot2
bindkey . _rationalise-dot2
bindkey -M isearch . self-insert
The zle calls inside the function don't pass argv through, but that
doesn't matter in practice.
Tweak to taste.
next prev parent reply other threads:[~2020-05-10 14:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAN=4vMr_8j03P2oY0+9SLgBnMWMtGtrnUag7fte =18VnvUtRKg@mail.gmail.com>
2020-05-10 5:28 ` Dian M Fay
2020-05-10 7:06 ` Eric Cook
2020-05-10 7:09 ` Eric Cook
2020-05-10 14:21 ` Daniel Shahaf [this message]
2020-05-10 4:37 Dian M Fay
2020-05-10 4:43 ` Roman Perepelitsa
2020-05-10 5:58 ` Bart Schaefer
2020-05-10 6:28 ` Bart Schaefer
2020-05-10 17:17 ` Dian M Fay
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=20200510142136.282ecedb@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=zsh-workers@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).