Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 75 lines (61 sloc) 1.79 KB
#!/bin/bash
#Initialize variables to default values.
DUPECOUNT=5
NEWWINDOW=1
TABS=1
RESTTIME=0
#Set fonts for Help.
NORM=$(tput sgr0)
BOLD=$(tput bold)
#Help function
function HELP {
echo -e \\n"${BOLD}Help documentation for dupetab${NORM}"\\n
echo -e "${BOLD}Basic usage: ${NORM}dupetab [options] <URL to replicate>"\\n
echo "${BOLD}Options:${NORM}"
echo "${BOLD}-n${NORM} <count of tabs to open. Default is 5>"
echo "${BOLD}-s${NORM} <Sleep between tabs. Default is 0.>"
echo "${BOLD}-c${NORM} -- Use Current Window."
exit 1
}
#Check the number of arguments. If none are passed, print help and exit.
NUMARGS=$#
if [ $NUMARGS -eq 0 ]; then
HELP
fi
### Start getopts code ###
#Parse command line flags
#If an option should be followed by an argument, it should be followed by a ":".
#Notice there is no ":" after "h". The leading ":" suppresses error messages from
#getopts. This is required to get my unrecognized option code to work.
while getopts :n:s:ch FLAG; do
case $FLAG in
n) #Set option for number of Tabs
DUPECOUNT=$OPTARG
;;
s) #Set option for Sleep timer
RESTTIME=$OPTARG
;;
c) #set option for current window
NEWWINDOW=0
;;
h) #show help
HELP
;;
\?) #unrecognized option - show help
echo -e \\n"Option $OPTARG not allowed."
HELP
;;
esac
done
shift $((OPTIND-1)) #This tells getopts to move on to the next argument.
#Call Chrome by itself. This will create a new window instead of hijacking the existing one.
if [ $NEWWINDOW -eq 1 ]; then
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
fi
### Actually Open The Tabs ###
while [ $TABS -le $DUPECOUNT ]
do
open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $1
TABS=$(( $TABS + 1 ))
sleep $RESTTIME
done