aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Hiar <cody@hiar.ca>2021-02-01 13:59:10 -0700
committerCody Hiar <cody@hiar.ca>2021-02-01 13:59:10 -0700
commit722b0362df859e6524a26c2120e88be1518d0277 (patch)
tree836ccbe771193f7a9e711dc5859057716cb130ef
parent8866483844e64543a652590e2ec9aa40a5bb6ef4 (diff)
Session select script update
-rwxr-xr-xscripts/tmux_session_fzf29
-rw-r--r--stow/tmux/.tmux.conf2
2 files changed, 30 insertions, 1 deletions
diff --git a/scripts/tmux_session_fzf b/scripts/tmux_session_fzf
new file mode 100755
index 0000000..c093468
--- /dev/null
+++ b/scripts/tmux_session_fzf
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+# vim: set filetype=sh
+#
+# Author: Cody Hiar
+# Date: 2020-03-17
+#
+# Description: Select a tmux session with FZF
+#
+# Set options:
+# e: Stop script if command fails
+# u: Stop script if unset variable is referenced
+# x: Debug, print commands as they are executed
+# o pipefail: If any command in a pipeline fails it all fails
+#
+# IFS: Internal Field Separator
+set -euo pipefail
+IFS=$'\n\t'
+
+get_active_pane(){
+ local SESSION="${1}"
+ tmux list-windows -t "${SESSION}" | grep '(active)' | cut -c 1
+}
+
+TARGET=$(tmux ls | awk -F':' '{print $1}' | fzf-tmux -h)
+if [[ -n "${TARGET}" ]]; then
+ WINDOW=$(get_active_pane "${TARGET}")
+ echo "${TARGET}:${WINDOW}" >> ~/tmux.log
+ tmux switch-client -t "${TARGET}:${WINDOW}"
+fi
diff --git a/stow/tmux/.tmux.conf b/stow/tmux/.tmux.conf
index bfe8678..9c9d5bf 100644
--- a/stow/tmux/.tmux.conf
+++ b/stow/tmux/.tmux.conf
@@ -46,7 +46,7 @@ bind -Tcopy-mode-vi Enter send -X copy-pipe "tmux save-buffer - | xp"
bind C-t clock-mode
# Use fzf for switching sessions
unbind s
-bind s run-shell 'tmux_session_fzf_wrapper'
+bind s run-shell '~/.tmux/scripts/tmux_session_fzf'
# Renumber the windows
bind C-w run-shell "~/.tmux/scripts/window_renum"