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

retrieving the results of last command?



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. I Know of 3 somewhat
cumbersome ways to do this:

1. Copying and pasting with the mouse.

2. Using `locate a-file` (which is a bit more cumbersome to me than to
most because I swapped the keys to ` and ~).

3. Using $(comm).


Is there a "faster" way than `` to perform command expansion?

I tried to code a widget to do this, but I this is as far as I got:

insert-last-command-output(){
    com="`fc -ln -1`"
    RBUFFER=`$com`
}
zle -N insert-last-command-output
bindkey "^X^L" insert-last-command-output

#(^X^L was the first free key I could remember...)

but is fails with:
% locate ipython.el
/usr/bla/ipython.el
% insert-last-command-output:1: command not found: locate ipython.el

Any hints?

Cheers,
Francisco



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