blob: 2d3e137d092a25ecafd71f0ee0a7b2e7bdabcbdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
|