Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 33 lines (29 sloc) 789 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
elif is-cygwin; then
cat /dev/clipboard
else
if command-exists xclip; then
xclip -out -selection clipboard
elif command-exists xsel; then
xsel --clipboard --output
else
message="clipboard-paste: Platform $GRML_OSTYPE not supported "
message+="or xclip/xsel not installed"
print $message >&2
return 1
fi
fi
}
clipboard-paste $@