aboutsummaryrefslogtreecommitdiff
path: root/tmuxrdr/plugin/bin/last
diff options
context:
space:
mode:
Diffstat (limited to 'tmuxrdr/plugin/bin/last')
-rwxr-xr-xtmuxrdr/plugin/bin/last25
1 files changed, 25 insertions, 0 deletions
diff --git a/tmuxrdr/plugin/bin/last b/tmuxrdr/plugin/bin/last
new file mode 100755
index 00000000..2d3e137d
--- /dev/null
+++ b/tmuxrdr/plugin/bin/last
@@ -0,0 +1,25 @@
+#!/bin/sh
+# tmux prefix+L (switch-client -l): back to the previously focused workspace --
+# herdr's workspace is tmux's session. `last window` is tmux's prefix+l
+# (last-window): this machine's tmux.conf took l for select-pane -R, so it has
+# no key there and none here, but the : prompt has it. Going back focuses the
+# old one, which track-focus records, so repeating toggles -- as in tmux.
+. "$(dirname "$0")/../lib.sh"
+
+dir="$(state_dir)"
+case "${1:-}" in
+window)
+ ws="$(pane_info "$(active_pane)" workspace_id)"
+ t="$(cat "$dir/tab.$(key_of "$ws").previous" 2>/dev/null || true)"
+ [ -n "$t" ] && "$H" tab get "$t" >/dev/null 2>&1 || fail "no last window"
+ "$H" tab focus "$t" >/dev/null
+ ;;
+session)
+ w="$(cat "$dir/workspace.previous" 2>/dev/null || true)"
+ [ -n "$w" ] && "$H" workspace get "$w" >/dev/null 2>&1 || fail "can't find last session"
+ "$H" workspace focus "$w" >/dev/null
+ ;;
+*)
+ fail "usage: last window|session"
+ ;;
+esac