tmux mapping choose session

This commit is contained in:
thek4n 2024-10-21 12:18:51 +03:00
parent 9d0568160d
commit 0f001c52d5
3 changed files with 35 additions and 5 deletions

View File

@ -1,6 +1,6 @@
declare -r -A TARGETS=( declare -r -A TARGETS=(
["colors"]=".config/terminal-colors.d" ["colors"]=".config/terminal-colors.d"
["tmux"]=".config/tmux .tmux .config/systemd/user/tmux.service .local/bin/tmux_start_session.sh .local/bin/tmux_attach_session.sh" ["tmux"]=".config/tmux .tmux .config/systemd/user/tmux.service .local/bin/tmux_start_session.sh .local/bin/tmux_attach_session.sh .local/bin/tmux_choose_session.sh"
["bash"]=".config/bash .bashrc .profile %tmux %colors" ["bash"]=".config/bash .bashrc .profile %tmux %colors"
["zsh"]="%bash .config/zsh .zshenv .inputrc" ["zsh"]="%bash .config/zsh .zshenv .inputrc"
["alacritty"]=".config/alacritty" ["alacritty"]=".config/alacritty"

View File

@ -24,9 +24,6 @@ bind WheelDownPane send-keys -N 2 scroll-Down
bind F12 send-keys F12 bind F12 send-keys F12
bind s choose-tree-index
# View current pane in editor # View current pane in editor
bind-key y { bind-key y {
capture-pane -J capture-pane -J
@ -193,4 +190,6 @@ bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 2 scroll-down
# Session managment # Session managment
bind f display-popup -EE '~/.local/bin/tmux_start_session.sh' bind s display-popup -w 80% -h 80% -EE -T 'Attach existing session' '~/.local/bin/tmux_choose_session.sh'
bind f display-popup -EE -T 'Start new session' '~/.local/bin/tmux_start_session.sh'
bind a choose-tree-index

View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
export FZF_DEFAULT_OPTS="\
--cycle \
--pointer='' \
--marker='+' \
--color='pointer:green' \
--bind \
ctrl-/:toggle-preview,\
ctrl-a:toggle-all,\
ctrl-p:preview-up,\
ctrl-n:preview-down,\
ctrl-u:clear-query,\
ctrl-q:toggle+down,\
tab:replace-query,\
shift-tab:toggle\
"
declare sessions
sessions="$(tmux list-session -F '#S')"
readonly sessions
declare session
session="$(echo "${sessions}" | fzf +m --preview-window 75%,follow --preview 'tmux capture-pane -p -e -t {1}')"
readonly session
if [[ -n "${session}" ]]; then
tmux switch-client -t "${session}"
fi