Skip to content

Instantly share code, notes, and snippets.

@kshimo69
Created March 31, 2012 02:38
Show Gist options
  • Save kshimo69/2258779 to your computer and use it in GitHub Desktop.
Save kshimo69/2258779 to your computer and use it in GitHub Desktop.
zshで直前のコマンドをクリップボードにコピーする
if which pbcopy >/dev/null 2>&1 ; then
# Mac
COPY='pbcopy'
elif which xsel >/dev/null 2>&1 ; then
# Linux
COPY='xsel --input --clipboard'
elif which putclip >/dev/null 2>&1 ; then
# Cygwin
COPY='putclip'
fi
copy-prev-cmd-to-clipboard () {
tail -1 $HISTFILE | perl -e '<> =~ m/;(.+)/; print $1;' | $COPY
}
zle -N copy-prev-cmd-to-clipboard
bindkey '^x^p' copy-prev-cmd-to-clipboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment