aboutsummaryrefslogtreecommitdiff
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
parent6fd8e231c6a9f080c6271da69f3b93d581cc3c6b (diff)
downloadscripts-872e287d1242a2baff74784f9245a4446c6455d3.tar.gz
scripts-872e287d1242a2baff74784f9245a4446c6455d3.zip
Script for window size and for npm-start on tmux window.
-rwxr-xr-xsetWindowSize.sh50
-rwxr-xr-xtmux/tmux-npmStart.sh45
2 files changed, 95 insertions, 0 deletions
diff --git a/setWindowSize.sh b/setWindowSize.sh
new file mode 100755
index 0000000..76268dd
--- /dev/null
+++ b/setWindowSize.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# setWindowSize.sh: Sets the selected window size
+#
+# Usage: template.sh [-ac] [-b OPTARG] FILE...
+
+usageMessage="Usage: ${0} [-ac] [-b OPTARG] FILE..."
+
+error() {
+ printf '%s error: %s\n' "$0" "$*" >&2
+}
+
+errorAndUsage() {
+ printf '%s error: %s\n%s\n' "$0" "$*" "$usageMessage" >&2
+}
+
+# Process options
+while getopts ':ab:c' opt; do
+ case $opt in
+
+ 'a' )
+ echo a
+ ;;
+
+ 'b' )
+ echo b "$OPTARG"
+ ;;
+
+ 'c' )
+ echo c
+ ;;
+
+ '?' )
+ printf '%s\n' "$usageMessage" >&2
+ exit 1
+
+ esac
+done
+shift $((OPTIND - 1))
+
+resolution="$(\
+printf \
+'854 480
+720 480
+800 600
+1280 720
+1920 1080' |
+ dmenu -l 5 -p 'Resolution:')"
+
+xdotool getwindowfocus -- windowsize $resolution
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