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

Re: retrieving the results of last command?



On May 20,  2:18pm, Francisco Borges wrote:
}
} Often I'm in the situation of using say:
} 
} % locate a-file
} /usr/share/prog/a-file
} %
} 
} Then I want to use the pathname to copy the file.

The least computationally expensive way to do this is to save the output
in the first place.

E.g., Functions/Zle/keeper in the current dev versions of zsh, available
from the SourceForge CVS server.  You might even want to add

    locate() { command locate "$@" | keep }

Another trick that I do is

    # Imaginative function naming here, I know
    esc-backquote() { BUFFER='$( '"$BUFFER"' )'; CURSOR=0 }
    zle -N esc-backquote
    bindkey '\e`' esc-backquote

Then I can search through the history any way I like and when I find the
command whose output I want to capture, type ESC-` to wrap it in $( ... ).
I also have

    bindkey -s '\ev' '\e`vi '

so that ESC-v leaves me with "vi $( ... )" but I don't use that one much
any more, for some reason.



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