mirror of
https://github.com/tmux-plugins/tmux-continuum.git
synced 2024-11-22 03:08:48 +00:00
Do not auto-restore tmux env if there's another tmux server already running
This commit is contained in:
parent
4939459f33
commit
ab3e951cfa
@ -1,6 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
### master
|
### master
|
||||||
|
- do not auto-restore tmux environment if another tmux server is already running
|
||||||
|
(we don't want to duplicate stuff)
|
||||||
- bugfixes for 'tmux auto start' OS X Terminal.app and iTerm scripts
|
- bugfixes for 'tmux auto start' OS X Terminal.app and iTerm scripts
|
||||||
|
|
||||||
### v2.1.0, 2015-02-18
|
### v2.1.0, 2015-02-18
|
||||||
|
@ -10,6 +10,33 @@ auto_restore_enabled() {
|
|||||||
[ "$auto_restore_value" == "on" ] && [ ! -f "$auto_restore_halt_file" ]
|
[ "$auto_restore_value" == "on" ] && [ ! -f "$auto_restore_halt_file" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
current_tmux_server_pid() {
|
||||||
|
echo "$TMUX" |
|
||||||
|
cut -f2 -d","
|
||||||
|
}
|
||||||
|
|
||||||
|
all_tmux_processes() {
|
||||||
|
ps -Ao "command pid" |
|
||||||
|
\grep "^tmux"
|
||||||
|
}
|
||||||
|
|
||||||
|
tmux_processes_except_current_server() {
|
||||||
|
all_tmux_processes |
|
||||||
|
\grep -v " $(current_tmux_server_pid)$"
|
||||||
|
}
|
||||||
|
|
||||||
|
number_tmux_processes_except_current_server() {
|
||||||
|
all_tmux_processes |
|
||||||
|
\grep -v " $(current_tmux_server_pid)$" |
|
||||||
|
wc -l |
|
||||||
|
sed "s/ //g"
|
||||||
|
}
|
||||||
|
|
||||||
|
another_tmux_server_running() {
|
||||||
|
# there are 2 tmux processes (current tmux server + 1) on tmux startup
|
||||||
|
[ "$(number_tmux_processes_except_current_server)" -gt 1 ]
|
||||||
|
}
|
||||||
|
|
||||||
fetch_and_run_tmux_resurrect_restore_script() {
|
fetch_and_run_tmux_resurrect_restore_script() {
|
||||||
# give tmux some time to start and source all the plugins
|
# give tmux some time to start and source all the plugins
|
||||||
sleep 1
|
sleep 1
|
||||||
@ -20,7 +47,7 @@ fetch_and_run_tmux_resurrect_restore_script() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
if auto_restore_enabled; then
|
if auto_restore_enabled && ! another_tmux_server_running; then
|
||||||
fetch_and_run_tmux_resurrect_restore_script
|
fetch_and_run_tmux_resurrect_restore_script
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user