# HG changeset patch # User Meredith Howard # Date 1699570445 21600 # Node ID cb91318a522ecafcde10e7db08c22e982f9de1d0 # Parent 532c7964b23fbb23d87439f6f6068a5e827cae83 Add tmux popup bindings diff --git a/.tmux.conf b/.tmux.conf --- a/.tmux.conf +++ b/.tmux.conf @@ -40,6 +40,7 @@ set -g set-titles-string "#h(#S)" source-file ~/.tmux/screen-keys.conf source-file ~/.tmux/vim-keys.conf +source-file ~/.tmux/popup.conf bind S choose-session bind @ choose-window 'join-pane -h -s "%%"' diff --git a/.tmux/popup.conf b/.tmux/popup.conf new file mode 100644 --- /dev/null +++ b/.tmux/popup.conf @@ -0,0 +1,16 @@ +# Open a floating pane running tmux with a session named floating. If inside +# that floating window, detach. +bind '~' if-shell -F '#{==:#{session_name},floating}' { + detach-client +} { + set -gF '@last_session_name' '#S' + popup -d '#{pane_current_path}' -xC -yC -w70% -h70% -E 'tmux new -A -s floating' +} + +# Normal break pane, but if inside a floating session, breaks pane back into +# the most recently opened parent session. +bind ! if-shell -F '#{!=:#{session_name},floating}' { + break-pane +} { + run-shell 'bash -c "tmux break-pane -s floating -t \"$(tmux show -gvq '@last_session_name'):\""' +}