Skip to content

Instantly share code, notes, and snippets.

@yotamoron
Last active December 26, 2015 01:49
Show Gist options
  • Save yotamoron/7074005 to your computer and use it in GitHub Desktop.
Save yotamoron/7074005 to your computer and use it in GitHub Desktop.
A tiny script to refocus on a terminal once a command has finished running. You will need xdotool installed.
#!/bin/bash
WINDOW_NAME=`xdotool getwindowname $WINDOWID`
shopt -s expand_aliases
source ~/.aliases
eval $@
xdotool windowactivate --sync $WINDOWID
CURRENT_WINDOW_NAME=`xdotool getwindowname $WINDOWID`
while [ "$CURRENT_WINDOW_NAME" != "$WINDOW_NAME" ]; do
xdotool key --window $WINDOWID Ctrl+Right
CURRENT_WINDOW_NAME=`xdotool getwindowname $WINDOWID`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment