Add session switcher popup binding
This commit is contained in:
parent
8c92370420
commit
002c2ba9b8
26
session.sh
Executable file
26
session.sh
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
sessions=()
|
||||||
|
|
||||||
|
# Get list of predefined session layouts
|
||||||
|
for item in $HOME/.local/share/tmux/layouts/session-*; do
|
||||||
|
sessions+=(${item#$HOME/.local/share/tmux/layouts/session-})
|
||||||
|
done
|
||||||
|
|
||||||
|
# Get list of existing sessions
|
||||||
|
sessions+=($(tmux list-sessions | awk -F: '{print $1}'))
|
||||||
|
|
||||||
|
# Pick the session with fzf (remove duplicates)
|
||||||
|
session=$(
|
||||||
|
echo "${sessions[@]}" | tr ' ' '\n' | sort -u |
|
||||||
|
fzf --layout=reverse --info=hidden --border=rounded --cycle
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create the session if it doesn't alreayd exist
|
||||||
|
tmux list-sessions | grep "^$session:" &> /dev/null || \
|
||||||
|
tmux new-session -Ads $session -c $HOME
|
||||||
|
|
||||||
|
# Switch to the session
|
||||||
|
tmux switch-client -t $session
|
@ -64,6 +64,8 @@ if -b '[ "`uname`" = "Darwin" ]' \
|
|||||||
|
|
||||||
# Open a popup with running the default shell
|
# Open a popup with running the default shell
|
||||||
bind C-t display-popup -d '#{pane_current_path}' -E '$SHELL'
|
bind C-t display-popup -d '#{pane_current_path}' -E '$SHELL'
|
||||||
|
# Open a popup with session creator/switcher
|
||||||
|
bind C-s display-popup -B -w 60 -h 10 -E '~/.config/tmux/session.sh'
|
||||||
|
|
||||||
# Restore old next/previous window bindings
|
# Restore old next/previous window bindings
|
||||||
bind C-n next-window
|
bind C-n next-window
|
||||||
|
Loading…
x
Reference in New Issue
Block a user