Skip to content

Instantly share code, notes, and snippets.

@drobune
Created February 10, 2016 07:33
Show Gist options
  • Save drobune/4b30926ab253de22d604 to your computer and use it in GitHub Desktop.
Save drobune/4b30926ab253de22d604 to your computer and use it in GitHub Desktop.
#!/bin/bash
base=`basename $0 | sed -e 's/\.sh$//g'`
cmd=`echo $base | awk -F '_' '{print $1}'`
keystroke=`echo $base | sed -e 's/^[^_]\+_//g'`
id=`xdotool getwindowfocus`
case $cmd in
key)
xdotool key --window $id "$keystroke" > /dev/null 2>&1
;;
type)
echo -n "$keystroke" | xclip -i -selection clipboard
xdotool key --window $id "ctrl+v" > /dev/null 2>&1
;;
*)
echo "usage: ln -s $0 {key|type}_<keystroke>.sh"
exit 1;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment