From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8729 invoked from network); 10 Dec 2006 00:33:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 10 Dec 2006 00:33:08 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 79586 invoked from network); 10 Dec 2006 00:33:00 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Dec 2006 00:33:00 -0000 Received: (qmail 23981 invoked by alias); 10 Dec 2006 00:32:50 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11074 Received: (qmail 23969 invoked from network); 10 Dec 2006 00:32:49 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 10 Dec 2006 00:32:49 -0000 Received: (qmail 78256 invoked from network); 10 Dec 2006 00:32:49 -0000 Received: from customer-domains.icp-qv1-irony11.iinet.net.au (203.59.1.151) by a.mx.sunsite.dk with SMTP; 10 Dec 2006 00:32:45 -0000 Received: from 210-84-4-106.dyn.iinet.net.au (HELO mail.endbracket.net) ([210.84.4.106]) by customer-domains.icp-qv1-irony11.iinet.net.au with ESMTP; 10 Dec 2006 08:32:41 +0800 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAIvkekXSVARq/2dsb2JhbAA X-IronPort-AV: i="4.09,517,1157299200"; d="scan'208"; a="81394510:sNHT20054493" Received: from [192.168.1.7] (dove.endbracket.net [192.168.1.7]) by mail.endbracket.net (Postfix) with ESMTP id 886EA36A52 for ; Sun, 10 Dec 2006 11:32:39 +1100 (EST) Message-ID: <457B55D3.9030003@mikelward.com> Date: Sun, 10 Dec 2006 11:33:23 +1100 From: Mikel Ward User-Agent: Thunderbird 2.0a1 (Windows/20060724) MIME-Version: 1.0 To: zsh-users@sunsite.dk Subject: zsh widget to resolve symlinks References: <457B444E.2020207@mikelward.com> <457B5073.90206@mikelward.com> In-Reply-To: <457B5073.90206@mikelward.com> X-Enigmail-Version: 0.94.1.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Here's a working version of the widget to expand a shell word into its canonical path. It turns out copy-region-as-kill doesn't use killring but rather CUTBUFFER. This is a little confusing! I'm also surprised that CUTBUFFER persists invocations of zle, yet it isn't set in the top-level interactive shell. If I don't reset CUTBUFFER as the first thing I do, invoking the widget for a second time on an empty command line inserts the result of the previous invocation, for example: > ls .zshrc<^X /> expands to > ls /home/michael/etc/zshrc but then > <^X /> expands to > /home/michael/etc/zshrc The only problem I'm aware of with this version is where the file name contains spaces. I can't think of a way to easily do this, since we have the copy-prev-shell-word widget, but no equivalent kill-prev-shell-word that I would need to update the display. (I could get the word, but how would I overwrite it with its real path?) expand-word-path () { CUTBUFFER= zle backward-word zle set-mark-command zle forward-word zle copy-region-as-kill local word=$CUTBUFFER local realpath=$(realpath $word 2>/dev/null) if test -n "$realpath" then zle backward-kill-word zle -U "$realpath" fi }