Skip to content

Add option to allow kill the default sessions created when tmux server starts #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down
9 changes: 9 additions & 0 deletions scripts/continuum_restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ 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
local resurrect_restore_script_path="$(get_tmux_option "$resurrect_restore_path_option" "")"
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() {
Expand Down
3 changes: 3 additions & 0 deletions scripts/variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down