aboutsummaryrefslogtreecommitdiff
path: root/tmux
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-11-24 22:17:55 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2022-11-24 22:17:55 +0100
commit872e287d1242a2baff74784f9245a4446c6455d3 (patch)
treec8ae5192f9d616e07e4561cbf58a1151656ab795 /tmux
parent6fd8e231c6a9f080c6271da69f3b93d581cc3c6b (diff)
downloadscripts-872e287d1242a2baff74784f9245a4446c6455d3.tar.gz
scripts-872e287d1242a2baff74784f9245a4446c6455d3.zip
Script for window size and for npm-start on tmux window.
Diffstat (limited to 'tmux')
-rwxr-xr-xtmux/tmux-npmStart.sh45
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