diff options
author | Cody Hiar <cody@hiar.ca> | 2021-01-28 08:34:35 -0700 |
---|---|---|
committer | Cody Hiar <cody@hiar.ca> | 2021-01-28 08:34:35 -0700 |
commit | 8866483844e64543a652590e2ec9aa40a5bb6ef4 (patch) | |
tree | 3e69fa22b465f11c66f574924228edba4d2e6cc5 /scripts/window_renum | |
parent | 1b3a041521e3bb59febd21d6f86f1881d86d971e (diff) |
Updating scripts
Diffstat (limited to 'scripts/window_renum')
-rwxr-xr-x | scripts/window_renum | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/window_renum b/scripts/window_renum new file mode 100755 index 0000000..ef0a87f --- /dev/null +++ b/scripts/window_renum @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# vim: set filetype=sh +# +# Author: Unknown +# Date: 2016-11-09 +# +# Description: Renumber tmux windows (1, 3, 4, 6) -> (1, 2, 3, 4) + +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 |