Last active
December 31, 2015 07:39
-
-
Save rowdyrotifer/f21519e4c31c35c93b70 to your computer and use it in GitHub Desktop.
Fall asleep while watching videos? Want your browser tab to close after X seconds? For OS X with Chrome/Safari. Example uses: "closebrowser chrome 3600" "closebrowser safari 3000"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [[ $1 == "chrome" ]] | |
then | |
echo "Closing active tab of Google Chrome in $2 seconds." | |
sleep $2 | |
osascript -e 'tell app "Google Chrome" to close active tab of front window' | |
elif [[ $1 == "safari" ]] | |
then | |
echo "Closing active tab of Safari in $2 seconds." | |
sleep $2 | |
osascript -e 'tell app "Safari" to close current tab of first window' | |
fi | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment