Created
October 8, 2022 09:50
-
-
Save LintaoAmons/22f6184b26bd5b93d8fe9f9276f50f75 to your computer and use it in GitHub Desktop.
Popup terminal with tmux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... your other config | |
bind-key -n M-3 run-shell 'toggle-tmux-popup' | |
# you can switch `M-3` to any keybindings you like. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 👻 put this file into your $PATH, normally `~/.local/bin/toggle-tmux-popup` | |
# 👻 this script should have runable permission. | |
if [ "$(tmux display-message -p -F "#{session_name}")" = "popup" ];then | |
tmux detach-client | |
else | |
tmux popup -d '#{pane_current_path}' -xC -yC -w80% -h75% -E "tmux attach -t popup || tmux new -s popup" | |
fi |
@LintaoAmons the -A
option can auto create new session if it's not exist.
#! /usr/bin/env bash
tmux_popup_session_name="_popup"
if [ "$(tmux display-message -p -F "#{session_name}")" = "${tmux_popup_session_name}" ];then
tmux detach-client
else
tmux popup -d '#{pane_current_path}' -xC -yC -w80% -h80% -E\
"tmux new-session -A -s ${tmux_popup_session_name}"
fi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's no need to use
run-shell
, the if-check can be done using theif-shell
command with the-F
option. The above snippet simplified:This is also significantly more readable. Though, I think it requires a more recent tmux version.