2015-02-17 16:13:21 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
2015-02-18 14:14:11 +00:00
|
|
|
source "$CURRENT_DIR/../helpers.sh"
|
2015-02-17 16:13:21 +00:00
|
|
|
source "$CURRENT_DIR/../variables.sh"
|
|
|
|
|
|
|
|
template() {
|
|
|
|
local tmux_start_script="$1"
|
2015-02-18 15:24:01 +00:00
|
|
|
local is_fullscreen="$2"
|
|
|
|
|
|
|
|
local fullscreen_tag=""
|
|
|
|
if [ "$is_fullscreen" == "true" ]; then
|
|
|
|
# newline and spacing so tag is aligned with other tags in template
|
|
|
|
fullscreen_tag=$'\n <string>fullscreen</string>'
|
|
|
|
fi
|
|
|
|
|
2015-02-17 16:13:21 +00:00
|
|
|
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>
|
2015-02-18 15:24:01 +00:00
|
|
|
<string>${tmux_start_script}</string>$fullscreen_tag
|
2015-02-17 16:13:21 +00:00
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOF
|
|
|
|
echo "$content"
|
|
|
|
}
|
|
|
|
|
2015-02-18 14:14:11 +00:00
|
|
|
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
|
2015-02-18 15:24:01 +00:00
|
|
|
echo "true"
|
2015-02-18 14:14:11 +00:00
|
|
|
else
|
2015-02-18 15:24:01 +00:00
|
|
|
echo "false"
|
2015-02-18 14:14:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-02-17 16:13:21 +00:00
|
|
|
main() {
|
2015-02-18 14:14:11 +00:00
|
|
|
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")"
|
2015-02-18 15:24:01 +00:00
|
|
|
local tmux_start_script_path="${CURRENT_DIR}/osx_${iterm_or_terminal_value}_start_tmux.sh"
|
2015-02-18 14:14:11 +00:00
|
|
|
|
2015-02-18 15:24:01 +00:00
|
|
|
local launchd_plist_file_content="$(template "$tmux_start_script_path" "$fullscreen_option_value")"
|
2015-02-17 16:13:21 +00:00
|
|
|
echo "$launchd_plist_file_content" > "$osx_auto_start_file_path"
|
|
|
|
}
|
|
|
|
main
|