Skip to content

Commit b849189

Browse files
author
Bruno Sutic
committed
Add alternate session binding prefix + S
1 parent ba297e6 commit b849189

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### master
44
- add other plugins list to the README
55
- update readme to reflect github organization change
6+
- add alternate session key binding `prefix + S`
67

78
### v1.0.0, 2014-06-01
89

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ don't need to look it up.
3333
`p`, `r` or `j` in `goto-session` prompt will switch you to the respective
3434
project.<br/>
3535
This is actually a Tmux feature and it helps a lot.
36+
- `prefix + S` switches to the last session
3637

3738
### Installation with [Tmux Plugin Manager](https://github.com/tmux-plugins/tpm) (recommended)
3839

goto_session.tmux

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
55
default_key_bindings="g"
66
tmux_option="@goto_session_key"
77

8+
default_key_bindings_alternate="S"
9+
tmux_option_alternate="@goto_alternate_session_key"
10+
811
# tmux show-option "q" (quiet) flag does not set return value to 1, even though
912
# the option does not exist. This function patches that.
1013
get_tmux_option() {
@@ -21,12 +24,24 @@ get_tmux_option() {
2124
# Multiple bindings can be set. Default binding is "g".
2225
set_goto_session_bindings() {
2326
local key_bindings=$(get_tmux_option "$tmux_option" "$default_key_bindings")
27+
local key
2428
for key in $key_bindings; do
2529
tmux bind-key "$key" run-shell "$CURRENT_DIR/scripts/tmux_goto_session.sh"
2630
done
2731
}
2832

33+
set_alternate_session_binding() {
34+
local key_bindings=$(get_tmux_option "$tmux_option_alternate" "$default_key_bindings_alternate")
35+
local key
36+
for key in $key_bindings; do
37+
# switch to the last/alternate session
38+
tmux bind-key "$key" switch-client -l
39+
done
40+
}
41+
42+
2943
main() {
3044
set_goto_session_bindings
45+
set_alternate_session_binding
3146
}
3247
main

0 commit comments

Comments
 (0)