diff options
Diffstat (limited to 'tmux')
-rwxr-xr-x | tmux/tmux-npmStart.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tmux/tmux-npmStart.sh b/tmux/tmux-npmStart.sh new file mode 100755 index 0000000..00326e2 --- /dev/null +++ b/tmux/tmux-npmStart.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# tmux-npmStart.sh: Run 'npm start' on a new tmux window +# +# Usage: tmux-npmStart.sh [-r] + +usageMessage="Usage: ${0} [-r]" + +error() { + printf '%s error: %s\n' "$0" "$*" >&2 +} + +errorAndUsage() { + printf '%s error: %s\n%s\n' "$0" "$*" "$usageMessage" >&2 +} + +window=9 +name='npm start' +remainOnExit='' + +# Process options +while getopts ':r' opt; do + case $opt in + + 'r' ) + remainOnExit='y' + ;; + + '?' ) + printf '%s\n' "$usageMessage" >&2 + exit 1 + + esac +done +shift $((OPTIND - 1)) + +if tmux list-windows | grep -q "^${window}: ${name}"; then + tmux kill-window -t "$window" +else + if [ -z "$remainOnExit" ]; then + tmux new-window -db -t "$window" -n "$name" 'npm start' + else + tmux new-window -b -t "$window" -n "$name" 'tmux set -w remain-on-exit on; npm start' + fi +fi |