Browse code
feat(scripts): choose_tmux uses fzf
fiddlerwoaroof authored on 09/02/2020 22:37:30
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -1,5 +1,5 @@ |
1 |
-#!/usr/bin/env zsh |
|
2 |
-tmux ls |
|
1 |
+#!/usr/bin/env zsh |
|
2 |
+tmux start |
|
3 | 3 |
|
4 | 4 |
attach_tmux () { |
5 | 5 |
TMUX_SESSION="$1" |
... | ... |
@@ -11,12 +11,19 @@ new_tmux () { |
11 | 11 |
exec tmux new-session -s "$TMUX_SESSION" |
12 | 12 |
} |
13 | 13 |
|
14 |
-if [[ x"$1" == x ]]; then |
|
14 |
+tmux_sessions() { |
|
15 |
+ echo |
|
16 |
+ tmux ls |
|
17 |
+} |
|
15 | 18 |
|
16 |
- echo -n "Which session? " |
|
17 |
- read TMUX_SESSION |
|
19 |
+complete_sessions() { |
|
20 |
+ tmux_sessions | fzf --bind alt-enter:print-query -n 1 -d: | cut -d: -f1 |
|
21 |
+} |
|
22 |
+ |
|
23 |
+if [[ x"$1" == x ]]; then |
|
24 |
+ TMUX_SESSION="$(complete_sessions)" |
|
18 | 25 |
|
19 |
- if [[ "$TMUX_SESSION"x != ""x ]]; then |
|
26 |
+ if [[ -n "$TMUX_SESSION" ]]; then |
|
20 | 27 |
attach_tmux "$TMUX_SESSION" && exit 0 |
21 | 28 |
fi |
22 | 29 |
|