aboutsummaryrefslogtreecommitdiff
path: root/window_renum.sh
diff options
context:
space:
mode:
authorCody Hiar <cody.hiar@investopedia.com>2016-11-09 19:46:00 -0700
committerCody Hiar <cody.hiar@investopedia.com>2016-11-09 19:46:00 -0700
commit9ad7425bed6329c069a933653a0c12960c0c823a (patch)
treef9107d0c8a62565df98b49de89f72e36f5dd35f0 /window_renum.sh
parentd22bfebede82a9b09539b497db3ca84595b7ade6 (diff)
A couple more updates for better tmuxing
Diffstat (limited to 'window_renum.sh')
-rwxr-xr-xwindow_renum.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/window_renum.sh b/window_renum.sh
new file mode 100755
index 0000000..19e5825
--- /dev/null
+++ b/window_renum.sh
@@ -0,0 +1,15 @@
+for session in $(tmux ls | awk -F: '{print $1}') ; do
+ active_window=$(tmux lsw -t ${session} | awk -F: '/\(active\)$/ {print $1}')
+ inum=1
+ for window in $(tmux lsw -t ${session} | awk -F: '{print $1}') ;do
+ if [ ${window} -gt ${inum} ] ;then
+ echo "${session}:${window} -> ${session}:${inum}"
+ tmux movew -d -s ${session}:${window} -t ${session}:${inum}
+ fi
+ if [ ${window} = ${active_window} ] ;then
+ new_active_window=${inum}
+ fi
+ inum=$((${inum}+1))
+ done
+ tmux select-window -t ${session}:${new_active_window}
+done