Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
executable file 30 lines (27 sloc) 743 Bytes
#!/bin/zsh
# Pastes data from the clipboard to stdout
function clipboard-paste() {
emulate -L zsh
# If there's no X11 display, then fallback to our hacky reimplementation. The
# data is populated by clipboard-copy.
if ! has-display; then
local fake_clipboard=/tmp/clipboard-data.txt
[[ -e $fake_clipboard ]] && cat $fake_clipboard
return
fi
if is-darwin; then
pbpaste
else
if command-exists xclip; then
xclip -out -selection clipboard
elif command-exists xsel; then
xsel --clipboard --output
else
message="clipboard-paste: Platform $OS_TYPE not supported "
message+="or xclip/xsel not installed"
print "$message" >&2
return 1
fi
fi
}
clipboard-paste "$@"