diff --git a/README.md b/README.md index 803acdc..aa313de 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,9 @@ Put `set -g @continuum-restore 'on'` in `tmux.conf` to enable this. Note: automatic restore happens **exclusively** on tmux server start. No other action (e.g. sourcing `tmux.conf`) triggers this. +To kill the default session (named "0") created when tmux server starts, +Put `set -g @continuum-kill-default 'on'` in `tmux.conf` to enable this. + #### Dependencies `tmux 1.9` or higher, `bash`, diff --git a/scripts/continuum_restore.sh b/scripts/continuum_restore.sh index 27afbc4..1a10b9a 100755 --- a/scripts/continuum_restore.sh +++ b/scripts/continuum_restore.sh @@ -10,6 +10,11 @@ auto_restore_enabled() { [ "$auto_restore_value" == "on" ] && [ ! -f "$auto_restore_halt_file" ] } +auto_kill_default_enabled() { + local auto_kill_default_value="$(get_tmux_option "$auto_kill_default_option" "$auto_kill_default_default")" + [ "$auto_kill_default_value" == "on" ] +} + fetch_and_run_tmux_resurrect_restore_script() { # give tmux some time to start and source all the plugins sleep 1 @@ -17,6 +22,10 @@ fetch_and_run_tmux_resurrect_restore_script() { if [ -n "$resurrect_restore_script_path" ]; then "$resurrect_restore_script_path" fi + if auto_kill_default_enabled; then + # Kill the default session created when tmux server starts + tmux kill-session -t 0 + fi } main() { diff --git a/scripts/variables.sh b/scripts/variables.sh index 1ddda9e..16fe6a5 100644 --- a/scripts/variables.sh +++ b/scripts/variables.sh @@ -13,6 +13,9 @@ last_auto_save_option="@continuum-save-last-timestamp" auto_restore_option="@continuum-restore" auto_restore_default="off" +auto_kill_default_option="@continuum-kill-default" +auto_kill_default_default="off" + auto_restore_halt_file="${HOME}/tmux_no_auto_restore" # tmux auto start options