mirror of
https://github.com/zoriya/flake.git
synced 2026-08-15 18:43:42 +00:00
Make tmux session binding editable slots
This commit is contained in:
@@ -1,10 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
selected=$(find ~/projects ~/work -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
fi
|
||||
slots_dir="${XDG_DATA_HOME:-$HOME/.local/share}/tmux-sessionizer/slots"
|
||||
|
||||
pick_project() {
|
||||
find ~/projects ~/work -mindepth 1 -maxdepth 1 -type d | fzf
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--slot)
|
||||
slot_file="$slots_dir/$2"
|
||||
if [[ -s "$slot_file" ]]; then
|
||||
selected=$(<"$slot_file")
|
||||
else
|
||||
tmux display-message "tmux-sessionizer: slot '$2' is unbound (use prefix + C-${2^^} to set it)"
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
--set)
|
||||
selected=$(pick_project)
|
||||
[[ -z $selected ]] && exit 0
|
||||
mkdir -p "$slots_dir"
|
||||
printf '%s\n' "$selected" > "$slots_dir/$2"
|
||||
tmux display-message "tmux-sessionizer: bound slot '$2' -> $selected"
|
||||
;;
|
||||
"")
|
||||
selected=$(pick_project)
|
||||
;;
|
||||
*)
|
||||
selected=$1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
|
||||
@@ -49,10 +49,16 @@
|
||||
bind-key -T copy-mode-vi ] send-keys -X next-prompt
|
||||
|
||||
bind-key f run-shell "tmux neww tmux-sessionizer"
|
||||
bind-key C-h run-shell "tmux-sessionizer ~/projects/kyoo"
|
||||
bind-key C-t run-shell "tmux-sessionizer ~/projects/snow"
|
||||
bind-key C-s run-shell "tmux-sessionizer ~/projects/flake"
|
||||
bind-key C-n run-shell "tmux-sessionizer ~/projects/blog"
|
||||
# Jump to the project bound to each slot (per-host, stored on disk).
|
||||
bind-key C-h run-shell "tmux-sessionizer --slot h"
|
||||
bind-key C-t run-shell "tmux-sessionizer --slot t"
|
||||
bind-key C-s run-shell "tmux-sessionizer --slot s"
|
||||
bind-key C-n run-shell "tmux-sessionizer --slot n"
|
||||
# Bind a slot: pick a project via fzf, then C-<key> jumps to it.
|
||||
bind-key C-H run-shell "tmux neww tmux-sessionizer --set h"
|
||||
bind-key C-T run-shell "tmux neww tmux-sessionizer --set t"
|
||||
bind-key C-S run-shell "tmux neww tmux-sessionizer --set s"
|
||||
bind-key C-N run-shell "tmux neww tmux-sessionizer --set n"
|
||||
|
||||
# suspend inner tmux (to allow nested sessions)
|
||||
bind @ { set prefix None; set key-table off }
|
||||
|
||||
Reference in New Issue
Block a user