aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2024-04-02 23:24:41 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2024-04-02 23:24:41 +0200
commitd8ce34981ecc54f444cae2faf7757f25b28a93f2 (patch)
treec7e59f2bf3421888e8c24557fbe923f35a82b4da
parent28ba77bba0b0569fa2a9e82986204da84bc029a6 (diff)
downloaddotfiles-d8ce34981ecc54f444cae2faf7757f25b28a93f2.tar.gz
tmux selector first draft
-rwxr-xr-xscripts/tmux_selector.sh28
-rw-r--r--sway/config.d/40-app-shortcuts.conf1
2 files changed, 29 insertions, 0 deletions
diff --git a/scripts/tmux_selector.sh b/scripts/tmux_selector.sh
new file mode 100755
index 0000000..3928df6
--- /dev/null
+++ b/scripts/tmux_selector.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+shopt -s extglob
+
+readonly TMUX_FORMAT='#{session_id};#{session_attached};#{session_name}'
+
+OPTIONS=$(
+echo new
+while IFS=';' read -r ID ATTACHED NAME; do
+ printf "%s\t|" "$ID"
+ printf " %s" "$NAME"
+ test $ATTACHED -ge 1 && printf " (attached)"
+
+ printf "\n"
+done <<< "$(tmux ls -F "$TMUX_FORMAT")"
+)
+
+CHOICE=$(fzf <<< "$OPTIONS" | awk -F'|' '{ print $1 }')
+test -z "$CHOICE" && exit 1
+
+echo $CHOICE
+
+case $CHOICE in
+ $+([0-9])* )
+ tmux attach -t $CHOICE ;;
+ new) tmux ;;
+ *)
+ exit 1;;
+esac
diff --git a/sway/config.d/40-app-shortcuts.conf b/sway/config.d/40-app-shortcuts.conf
index 53a2e71..051ffed 100644
--- a/sway/config.d/40-app-shortcuts.conf
+++ b/sway/config.d/40-app-shortcuts.conf
@@ -3,6 +3,7 @@
bindsym $mod+minus [app_id="org.keepassxc.KeePassXC"] scratchpad show
bindsym $mod+Return exec $term -e tmux
+bindsym $mod+Backslash exec $term -e tmux_selector.sh
bindsym $mod+Shift+Return exec "$term -t termite_floating"
bindsym $mod+o exec "dolphin"