Skip to content

Instantly share code, notes, and snippets.

@menixator
Created August 6, 2016 18:38
Show Gist options
  • Save menixator/efb724b4cb74884106b6a21bf7da9ab0 to your computer and use it in GitHub Desktop.
Save menixator/efb724b4cb74884106b6a21bf7da9ab0 to your computer and use it in GitHub Desktop.
Make global terminal shortcut work for sublime text
#!/usr/bin/env zsh
# Download this script
# Save it somewhere. Make it an executable with
# $ chmod +x terminal.zsh
# Then add a systemwide shortcut for this script
# and you're done!
# Get the current window id
ACTIVE=$(xdotool getactivewindow)
# Find all the sublime text windows that are open.
# Remember to remove the "(UNREGISTERED)" part if you
# have it registered.
SUBLIMES=$(xdotool search --name "\\- Sublime Text \\(UNREGISTERED\\)")
# Find the ACTIVE window id in the SUBLIME window ids
if [[ $SUBLIMES =~ $ACTIVE ]] ; then
# Use xdotool to send a keystroke to open the terminal in the
# project folder. Use the Terminal package to configure a
# hotkey. (https://packagecontrol.io/packages/Terminal)
xdotool key --window "$ACTIVE" F1
exit
fi
# I use urxvt as my terminal. Open your default terminal here.
exec ~/bin/urxvt.wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment