Skip to content

Instantly share code, notes, and snippets.

@syphoxy
Last active February 27, 2018 01:32
Show Gist options
  • Save syphoxy/f0b76e1d6ca5476c705149abc727d31c to your computer and use it in GitHub Desktop.
Save syphoxy/f0b76e1d6ca5476c705149abc727d31c to your computer and use it in GitHub Desktop.
#!/bin/bash
readonly TERMINAL="${TERMINAL:-urxvt256c-ml}"
readonly EDITOR="${EDITOR:-vim}"
readonly FILE="$(mktemp)"
cleanup() {
test -f "$FILE" \
&& rm -f "$FILE"
}
trap cleanup EXIT
xclip -selection clipboard -out > "$FILE"
if tty -s; then
"$EDITOR" "$FILE"
else
"$TERMINAL" -e "$EDITOR" "$FILE"
fi
xclip -selection clipboard -in < "$FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment