Reputation: 731
I am using a function that I found in YADR which should insert the output of the last command.
# Use Ctrl-x,Ctrl-l to get the output of the last command
zmodload -i zsh/parameter
insert-last-command-output() {
LBUFFER+="$(eval $history[$((HISTCMD-1))])"
}
zle -N insert-last-command-output
bindkey "^X^L" insert-last-command-output
For some reason, it does not seem to work by pressing ctrl-x ctrl-l
but running
echo $(eval $history[$((HISTCMD-1))])
command on the terminal does produce the output of the last command.
Running bindkey -M viins
shows "^X^L" insert-last-command-output
as one of the entries. Therefore, the function is registered.
I don't really understand how the function works. I think that the variable LBUFFER
holds the output of all last commands but when I echo $LBUFFER
, it returns the function code.
Can anyone help me get this working?
Upvotes: 0
Views: 262
Reputation: 731
I finally found a solution.
I had been trying to use the shortcut inside tmux which did not work. However, outside tmux, everything worked. It turns out that tmux will not allow a shortcut with two keys. I changed the shortcut to just alt-L
and everything works.
Upvotes: 1