mirror of
https://github.com/tmux-plugins/tmux-continuum.git
synced 2024-11-22 11:18:47 +00:00
Enable easy 'tmux auto start' configuration
This commit is contained in:
parent
b0d0af9525
commit
61ff39584a
@ -1,6 +1,7 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
### master
|
### master
|
||||||
|
- enable "tmux auto start" for OS X
|
||||||
|
|
||||||
### v2.0.0, 2015-02-15
|
### v2.0.0, 2015-02-15
|
||||||
- enable automatic environment restore when tmux is started
|
- enable automatic environment restore when tmux is started
|
||||||
|
26
README.md
26
README.md
@ -1,16 +1,32 @@
|
|||||||
# tmux-resurrect-auto
|
# tmux-resurrect-auto
|
||||||
|
|
||||||
Continuous saving of tmux environment. Automatic restore when tmux is started.
|
Features:
|
||||||
|
|
||||||
|
- continuous saving of tmux environment
|
||||||
|
- automatic tmux start when computer/server is on
|
||||||
|
- automatic restore when tmux is started
|
||||||
|
|
||||||
|
These features enable uninterrupted tmux usage. No matter the computer or server
|
||||||
|
restarts, if the machine is on, tmux will be there how you left it off the last
|
||||||
|
time it was used.
|
||||||
|
|
||||||
#### Continuous saving
|
#### Continuous saving
|
||||||
|
|
||||||
After this plugin is installed, `tmux-resurrect` will save environment at the
|
Tmux environment will be saved at the interval of 15 minutes. All the saving
|
||||||
interval of 15 minutes. All the saving happens in the background without the
|
happens in the background without the impact to your workflow.
|
||||||
impact to your workflow.
|
|
||||||
|
This action starts automatically when the plugin is installed.
|
||||||
|
|
||||||
|
#### Automatic tmux start
|
||||||
|
|
||||||
|
Tmux is automatically started after the computer/server is turned on.
|
||||||
|
|
||||||
|
Put `set -g @resurrect-auto-tmux-start 'on'` in `tmux.conf` to enable this.
|
||||||
|
|
||||||
#### Automatic restore
|
#### Automatic restore
|
||||||
|
|
||||||
Last saved environment is automatically restored when tmux server is started.
|
Last saved environment is automatically restored when tmux is started.
|
||||||
|
|
||||||
Put `set -g @resurrect-auto-restore 'on'` in `tmux.conf` to enable this.
|
Put `set -g @resurrect-auto-restore 'on'` in `tmux.conf` to enable this.
|
||||||
|
|
||||||
Note: automatic restore happens **exclusively** on tmux server start. No other
|
Note: automatic restore happens **exclusively** on tmux server start. No other
|
||||||
|
@ -12,6 +12,10 @@ supported_tmux_version_ok() {
|
|||||||
$CURRENT_DIR/scripts/check_tmux_version.sh "$SUPPORTED_VERSION"
|
$CURRENT_DIR/scripts/check_tmux_version.sh "$SUPPORTED_VERSION"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_tmux_automatic_start() {
|
||||||
|
$CURRENT_DIR/scripts/handle_tmux_automatic_start.sh
|
||||||
|
}
|
||||||
|
|
||||||
add_resurrect_save_interpolation() {
|
add_resurrect_save_interpolation() {
|
||||||
local status_right_value="$(get_tmux_option "status-right" "")"
|
local status_right_value="$(get_tmux_option "status-right" "")"
|
||||||
local new_value="${save_command_interpolation}${status_right_value}"
|
local new_value="${save_command_interpolation}${status_right_value}"
|
||||||
@ -31,6 +35,8 @@ start_auto_restore_in_background() {
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
if supported_tmux_version_ok; then
|
if supported_tmux_version_ok; then
|
||||||
|
handle_tmux_automatic_start
|
||||||
|
|
||||||
# Don't start saving right after tmux is started.
|
# Don't start saving right after tmux is started.
|
||||||
# We wanna give user a chance to restore previous session.
|
# We wanna give user a chance to restore previous session.
|
||||||
set_last_save_timestamp
|
set_last_save_timestamp
|
||||||
|
28
scripts/handle_tmux_automatic_start.sh
Executable file
28
scripts/handle_tmux_automatic_start.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
source "$CURRENT_DIR/helpers.sh"
|
||||||
|
source "$CURRENT_DIR/variables.sh"
|
||||||
|
|
||||||
|
is_tmux_automatic_start_enabled() {
|
||||||
|
local auto_start_value="$(get_tmux_option "$auto_start_option" "$auto_start_default")"
|
||||||
|
[ "$auto_start_value" == "on" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
is_osx() {
|
||||||
|
[ $(uname) == "Darwin" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if is_tmux_automatic_start_enabled; then
|
||||||
|
if is_osx; then
|
||||||
|
$CURRENT_DIR/handle_tmux_automatic_start/osx_enable.sh
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if is_osx; then
|
||||||
|
$CURRENT_DIR/handle_tmux_automatic_start/osx_disable.sh
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
main
|
10
scripts/handle_tmux_automatic_start/osx_disable.sh
Executable file
10
scripts/handle_tmux_automatic_start/osx_disable.sh
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
source "$CURRENT_DIR/../variables.sh"
|
||||||
|
|
||||||
|
main() {
|
||||||
|
rm "$osx_auto_start_file_path" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
main
|
33
scripts/handle_tmux_automatic_start/osx_enable.sh
Executable file
33
scripts/handle_tmux_automatic_start/osx_enable.sh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
source "$CURRENT_DIR/../variables.sh"
|
||||||
|
|
||||||
|
template() {
|
||||||
|
local tmux_start_script="$1"
|
||||||
|
local content
|
||||||
|
read -r -d '' content <<-EOF
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>Label</key>
|
||||||
|
<string>${osx_auto_start_file_name}</string>
|
||||||
|
<key>ProgramArguments</key>
|
||||||
|
<array>
|
||||||
|
<string>${tmux_start_script}</string>
|
||||||
|
</array>
|
||||||
|
<key>RunAtLoad</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
EOF
|
||||||
|
echo "$content"
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local launchd_plist_file_content="$(template "$CURRENT_DIR/osx_terminal_start_tmux.sh")"
|
||||||
|
echo "$launchd_plist_file_content" > "$osx_auto_start_file_path"
|
||||||
|
}
|
||||||
|
main
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# for "true full screen" call the script with "true" as the first argument
|
# for "true full screen" call the script with "fullscreen" as the first argument
|
||||||
TRUE_FULL_SCREEN="$1"
|
TRUE_FULL_SCREEN="$1"
|
||||||
|
|
||||||
start_iterm_and_run_tmux() {
|
start_iterm_and_run_tmux() {
|
||||||
@ -52,7 +52,7 @@ resize_to_true_full_screen() {
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
start_iterm_and_run_tmux
|
start_iterm_and_run_tmux
|
||||||
if [ "$TRUE_FULL_SCREEN" == "true" ]; then
|
if [ "$TRUE_FULL_SCREEN" == "fullscreen" ]; then
|
||||||
resize_to_true_full_screen
|
resize_to_true_full_screen
|
||||||
else
|
else
|
||||||
resize_window_to_full_screen
|
resize_window_to_full_screen
|
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# for "true full screen" call the script with "true" as the first argument
|
# for "true full screen" call the script with "fullscreen" as the first argument
|
||||||
TRUE_FULL_SCREEN="$1"
|
TRUE_FULL_SCREEN="$1"
|
||||||
|
|
||||||
start_terminal_and_run_tmux() {
|
start_terminal_and_run_tmux() {
|
||||||
@ -39,7 +39,7 @@ resize_to_true_full_screen() {
|
|||||||
|
|
||||||
main() {
|
main() {
|
||||||
start_terminal_and_run_tmux
|
start_terminal_and_run_tmux
|
||||||
if [ "$TRUE_FULL_SCREEN" == "true" ]; then
|
if [ "$TRUE_FULL_SCREEN" == "fullscreen" ]; then
|
||||||
resize_to_true_full_screen
|
resize_to_true_full_screen
|
||||||
else
|
else
|
||||||
resize_window_to_full_screen
|
resize_window_to_full_screen
|
@ -14,3 +14,10 @@ auto_restore_option="@resurrect-auto-restore"
|
|||||||
auto_restore_default="off"
|
auto_restore_default="off"
|
||||||
|
|
||||||
auto_restore_halt_file="${HOME}/tmux_no_auto_restore"
|
auto_restore_halt_file="${HOME}/tmux_no_auto_restore"
|
||||||
|
|
||||||
|
# tmux auto start options
|
||||||
|
auto_start_option="@resurrect-auto-tmux-start"
|
||||||
|
auto_start_default="off"
|
||||||
|
|
||||||
|
osx_auto_start_file_name="Tmux.Start.plist"
|
||||||
|
osx_auto_start_file_path="${HOME}/Library/LaunchAgents/${osx_auto_start_file_name}"
|
||||||
|
Loading…
Reference in New Issue
Block a user