Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Neat hash -d trick
- X-seq: zsh-users 15471
- From: JÃrÃmie Roquet <arkanosis@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Neat hash -d trick
- Date: Fri, 22 Oct 2010 10:39:27 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=Cm03gIuix91KZVHPuZiyHV4pQ7lrKO0PVMwLdIq2kTY=; b=dbwsAlWiefc6NKFmsf8HZnLxw5ApHmA7lCSuXikzI4lVGBMYtjBFrzbGIIZnmdXS6s INU/MKPvrH3JZ9WssX/hSkaYIf3EPiyE4Ju5D91qGb33psEhWMMhQzNft1aE7xf68Zoh 7PTgI8GdN4yX2RCpk0I4BbOiMbHdz6xGBlQec=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=cJ6WUxp14FJ3whJBw+a4G7Fz7JshmF30m6MkCRW7c5SaDjUuCtvUsY7ma86cKGrt1O 0noJiU1O+EIUuZwWBznjZnkDUNnbamzsPwzPFp8dvcW2tF91Jw986B8c6SJZTExj9D+f 7v/241PBkmMuSDwMg11Tocd2Hz71yLeCLkSKc=
- In-reply-to: <AANLkTimewqEvxBaQwqv1Sp=+OOjwmK_cgghM=VVC-Db2@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <AANLkTikBOSBNfBHXDFdfiCkijVt5G5+-1UVFz_VqY3wZ@xxxxxxxxxxxxxx> <101021210513.ZM30802@xxxxxxxxxxxxxxxxxxxxxx> <AANLkTimewqEvxBaQwqv1Sp=+OOjwmK_cgghM=VVC-Db2@xxxxxxxxxxxxxx>
2010/10/22 Mikael Magnusson <mikachu@xxxxxxxxx>:
> # just type '...' to get '../..'
> rationalise-dot() {
> local MATCH
> if [[ $LBUFFER =~ '(^|/| | Â Â Â|'$'\n''|\||;|&)\.\.$' ]]; then
> ÂLBUFFER+=/
> Âzle self-insert
> Âzle self-insert
> else
> Âzle self-insert
> fi
> }
> zle -N rationalise-dot
> bindkey . rationalise-dot
> # without this, typing a . aborts incremental history search
> bindkey -M isearch . self-insert
>
> You only need the last line to avoid the problem of course.
I'm using something similar, though I'll probably use your test now
because the expansion isn't always appropriate :)
function magic-dot()
{
if [[ $LBUFFER = *. ]]; then
LBUFFER+=./
display-path $LBUFFER
elif [[ $LBUFFER = *../ ]]; then
LBUFFER+=../
display-path $LBUFFER
else
zle self-insert
fi
}
zle -N magic-dot
.. gives ../ so you can use completion without typing the /
... gives ../../
and so on
display-path() prints the target path under the current line, so that
I know where I'm going.
It's a simple trick using xterm control sequences; I don't guarantee
it'll work everywhere but at least it works everywhere I've tested it.
function display-path()
{
local newpath
newpath=`pwd`/`echo $1 | sed 's_\(.* \)\?\([^ ]\+\)$_\2_'`
echo -n "\e7\n\e[40m$newpath:A\e[0m\e[0K\e8\e[B\e[A"
}
The only problem I've with these tricks is when pasting paths with
dots in my shell, because ../../foo/bar becomes ../../../foo/bar
Best regards,
--
JÃrÃmie
Messages sorted by:
Reverse Date,
Date,
Thread,
Author