Skip to content

Instantly share code, notes, and snippets.

@gaving
Created November 11, 2010 09:45
Show Gist options
  • Select an option

  • Save gaving/672269 to your computer and use it in GitHub Desktop.

Select an option

Save gaving/672269 to your computer and use it in GitHub Desktop.
if which pbpaste > /dev/null; then
CLIPBOARD=pbpaste
elif which getclip > /dev/null; then
CLIPBOARD=getclip
fi
if [ -n "${CLIPBOARD+x}" ]; then
# insert wget with clipbaord content
paste-clipboard() {
LBUFFER="$($CLIPBOARD)"
}
zle -N paste-clipboard
bindkey "^Xv" paste-clipboard
# insert wget with clipboard content
wget-clipboard() {
URL="$($CLIPBOARD)"
URL_BASE_NAME=$(basename $URL)
LBUFFER="nocorrect wget '$($CLIPBOARD)' -O $URL_BASE_NAME"
}
zle -N wget-clipboard
bindkey "^Xw" wget-clipboard
# build git clone command from clipboard
git-clone-clipboard() {
REPO_URL="$($CLIPBOARD)"
REPO_BASE_NAME=${$(basename $REPO_URL)%.git}
LBUFFER="nocorrect git clone $REPO_URL $REPO_BASE_NAME"
}
zle -N git-clone-clipboard
bindkey "^Xg" git-clone-clipboard
fi
# git clone suffix
git-clone-suffix() { git clone $1 ${$(basename $1)%.git} }
alias -s 'git'='git-clone-suffix'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment