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

Re: Absolute pathnames similar to expand-cmd-path



On Jan 25,  5:22pm, Mikael Magnusson wrote:
> Subject: Re: Absolute pathnames similar to expand-cmd-path
>
> On 25 January 2011 16:56, David Evans <david.evans@xxxxxxxxxxxx> wrote:
> > expand-cmd-path is a great widget. Is there a similar thing for
> > turning the current word into an absolute path? Sometimes I'm typing
> > a ../../.. chain and would like to see how far I've gone. This
> > should be easy with a widget function and :a but I don't want to
> > write it if even less work is needed.
> 
> I have this lying around. It shouldn't be too hard to modify it to do
> what you want.
> 
> function _split_shell_arguments_under()
> {
>   local -a reply
>   split-shell-arguments
>   #have to duplicate some of modify-current-argument to get the word
>   #_under_ the cursor, not after.

The following seems to work for me, though sometimes it doesn't leave
the cursor where I expect:

    autoload -uZ modify-current-argument
    current-argument-absolute-path() {
      modify-current-argument '$ARG:a'
    }
    zle -N current-argument-absolute-path



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