From 872e287d1242a2baff74784f9245a4446c6455d3 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Thu, 24 Nov 2022 22:17:55 +0100 Subject: Script for window size and for npm-start on tmux window. --- tmux/tmux-npmStart.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 tmux/tmux-npmStart.sh (limited to 'tmux') 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 -- cgit v1.2.1