Enable customizing 'tmux auto start' for OS X

This commit is contained in:
Bruno Sutic 2015-02-18 15:14:11 +01:00
parent 61ff39584a
commit dd82e770bd
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
3 changed files with 31 additions and 1 deletions

View File

@ -2,6 +2,7 @@
### master ### master
- enable "tmux auto start" for OS X - enable "tmux auto start" for OS X
- enable customizing "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

View File

@ -2,6 +2,7 @@
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/../helpers.sh"
source "$CURRENT_DIR/../variables.sh" source "$CURRENT_DIR/../variables.sh"
template() { template() {
@ -26,8 +27,32 @@ template() {
echo "$content" echo "$content"
} }
get_iterm_or_teminal_option_value() {
local options="$1"
if [[ "$options" =~ "iterm" ]]; then
echo "iterm"
else
# Terminal.app is the default console app
echo "terminal"
fi
}
get_fullscreen_option_value() {
local options="$1"
if [[ "$options" =~ "fullscreen" ]]; then
# space prepended bc this will be a script argument
echo " fullscreen"
else
echo ""
fi
}
main() { main() {
local launchd_plist_file_content="$(template "$CURRENT_DIR/osx_terminal_start_tmux.sh")" local options="$(get_tmux_option "$auto_start_config_option" "$auto_start_config_default")"
local iterm_or_terminal_value="$(get_iterm_or_teminal_option_value "$options")"
local fullscreen_option_value="$(get_fullscreen_option_value "$options")"
local launchd_plist_file_content="$(template "${CURRENT_DIR}/osx_${iterm_or_terminal_value}_start_tmux.sh${fullscreen_option_value}")"
echo "$launchd_plist_file_content" > "$osx_auto_start_file_path" echo "$launchd_plist_file_content" > "$osx_auto_start_file_path"
} }
main main

View File

@ -19,5 +19,9 @@ auto_restore_halt_file="${HOME}/tmux_no_auto_restore"
auto_start_option="@resurrect-auto-tmux-start" auto_start_option="@resurrect-auto-tmux-start"
auto_start_default="off" auto_start_default="off"
# comma separated list of additional options for tmux auto start
auto_start_config_option="@resurrect-auto-tmux-start-options"
auto_start_config_default=""
osx_auto_start_file_name="Tmux.Start.plist" osx_auto_start_file_name="Tmux.Start.plist"
osx_auto_start_file_path="${HOME}/Library/LaunchAgents/${osx_auto_start_file_name}" osx_auto_start_file_path="${HOME}/Library/LaunchAgents/${osx_auto_start_file_name}"