aboutsummaryrefslogtreecommitdiff
path: root/tools/window_menu
diff options
context:
space:
mode:
authorVasil Zlatanov <vasil.zlatanov@gmail.com>2015-04-12 13:05:47 +0200
committerVasil Zlatanov <vasil.zlatanov@gmail.com>2015-04-12 13:05:47 +0200
commit47a0a3f433f820fc78d180884f6ca376fba97b73 (patch)
tree587b80062ebdb947d26ca7a70e32b38b7d67ca45 /tools/window_menu
parent269e617fea39658233db38ad503030c4fe040e80 (diff)
downloaddotfiles-47a0a3f433f820fc78d180884f6ca376fba97b73.tar.gz
dotfiles-47a0a3f433f820fc78d180884f6ca376fba97b73.tar.bz2
dotfiles-47a0a3f433f820fc78d180884f6ca376fba97b73.zip
Tidy up everything :)
Diffstat (limited to 'tools/window_menu')
-rwxr-xr-xtools/window_menu40
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/window_menu b/tools/window_menu
new file mode 100755
index 0000000..950d252
--- /dev/null
+++ b/tools/window_menu
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+# Lets you switch between all windows in a way that minimizes keystrokes.
+
+# Two ways to order:
+# - If order=last, the windows are listed in the order that you last visited them in.
+# - If order=sequential, the windows are listed in number order.
+order=sequential
+ratmenu="~/.tools/ratmenu"
+
+source ~/.colors
+
+# Yes, bash is really necessary, because it's version of printf makes this
+# script possible. Regular bourne shell printf does NOT.
+
+window_index_str=$(ratpoison -c "info" | sed 's/^.*\([0-9]\)(.*$/\1/')
+if [ "$window_index_str" = "No window." ]; then
+ group_index=$($HOME/.tools/workspace current)
+ $ratmenu -style dreary -fg \"$COLOR0\" -bg \"$COLOR0\" "No windows in group $group_index"
+/bin/true
+else
+ ratpoison -c "echo $window_index_str"
+ echo "$window_index_str">/tmp/log
+ window_index=$[ $window_index_str + 1 ]
+ if [ $order = sequential ]; then
+ ( printf "$ratmenu -style dreary -fg \"$COLOR11\" -bg \"$COLOR0\" -io $window_index \
+ ";
+ ratpoison -c "windows %n %n %t" | sort -n | while read w x z; do
+ a=$(printf "%3q" $x); b="ratpoison -c \"select $x\"";
+ printf " %q\\ %q %q" "$a" "$z" "$b";
+ done; echo \;) | sh
+ elif [ $order = last ]; then
+ ( printf "$ratmenu -style dreary -fg \"$COLOR11\" -bg \"$COLOR0\" -io $window_index \
+ ";
+ ratpoison -c "windows %l %n %t" | sort -rn | while read w x z; do
+ a=$(printf "%3q" $x); b="ratpoison -c \"select $x\"";
+ printf " %q\\ %q %q" "$a" "$z" "$b";
+ done; echo \;) | sh
+ fi
+fi