Skip to content

Instantly share code, notes, and snippets.

@vrs
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrs/9622b96a0d3842ec812b to your computer and use it in GitHub Desktop.
Save vrs/9622b96a0d3842ec812b to your computer and use it in GitHub Desktop.
#!/bin/sh
# fix shift+ins pasting on gtk apps
# use by binding to shift+ins globally like so: ("S-<Insert>", spawn "pastefix")
# depends: xclip, xdotool
# inspired by https://github.com/wh5a/arch/commit/623faac500a0eeb31477b0374b3080eaf2ed3685
clipboard=$(xclip -o -selection clipboard)
xclip -o | xclip -selection clipboard
pid=$(xdotool getwindowfocus getwindowpid)
if head -c 1 >/dev/null 2>/dev/null /proc/$pid/maps && \
grep -q libgtk-x11 /proc/$pid/maps && \
[ x$(ps -p $pid -o comm=) != xvim ]
then
xdotool getwindowfocus key --clearmodifiers ctrl+v
else
xdotool getwindowfocus key --clearmodifiers shift+Insert
fi
echo -n "$clipboard" | xclip -selection clipboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment