diff --git a/docs/automatic_start.md b/docs/automatic_start.md index 2b7e443..2fff7bc 100644 --- a/docs/automatic_start.md +++ b/docs/automatic_start.md @@ -27,6 +27,10 @@ Config options: - `set -g @continuum-boot-options 'alacritty'` - start [alacritty](https://github.com/alacritty/alacritty) instead of `Terminal.app` - `set -g @continuum-boot-options 'alacritty,fullscreen'` - start `alacritty` in fullscreen +- `set -g @continuum-boot-options 'wezterm'` - start [wezterm](https://github.com/wez/wezterm) instead + of `Terminal.app` +- `set -g @continuum-boot-options 'wezterm,fullscreen'` - start `wezterm` + in fullscreen Note: The first time you reboot your machine and activate this feature you may be prompted about a script requiring access to a system program (i.e. - System Events). If this happens tmux will not start automatically and you will need diff --git a/scripts/handle_tmux_automatic_start/osx_enable.sh b/scripts/handle_tmux_automatic_start/osx_enable.sh index a7fea78..1ac0a2e 100755 --- a/scripts/handle_tmux_automatic_start/osx_enable.sh +++ b/scripts/handle_tmux_automatic_start/osx_enable.sh @@ -41,6 +41,8 @@ get_strategy() { echo "iterm" elif [[ "$options" =~ "kitty" ]]; then echo "kitty" + elif [[ "$options" =~ "wezterm" ]]; then + echo "wezterm" elif [[ "$options" =~ "alacritty" ]]; then echo "alacritty" else diff --git a/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh b/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh new file mode 100755 index 0000000..2bf6c9e --- /dev/null +++ b/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# Maintainer: Fernando Silva @fcaraujo +# # Contact maintainer for any change to this file. + +# for "true full screen" call the script with "fullscreen" as the first argument +TRUE_FULL_SCREEN="$1" + +start_terminal_and_run_tmux() { + osascript <<-EOF + tell application "WezTerm" + activate + delay 1 + tell application "System Events" to tell process "WezTerm" + set frontmost to true + keystroke "tmux" + key code 36 + end tell + end tell + EOF +} + +resize_window_to_full_screen() { + osascript <<-EOF + tell application "WezTerm" + activate + tell application "System Events" + if (every window of process "WezTerm") is {} then + keystroke "n" using command down + end if + + tell application "Finder" + set desktopSize to bounds of window of desktop + end tell + + set position of front window of process "WezTerm" to {0, 0} + set size of front window of process "WezTerm" to {item 3 of desktopSize, item 4 of desktopSize} + end tell + end tell + EOF +} + +resize_to_true_full_screen() { + osascript <<-EOF + tell application "WezTerm" + activate + delay 1 + tell application "System Events" to tell process "WezTerm" + if front window exists then + tell front window + if value of attribute "AXFullScreen" then + set value of attribute "AXFullScreen" to false + else + set value of attribute "AXFullScreen" to true + end if + end tell + end if + end tell + end tell + EOF +} + +main() { + start_terminal_and_run_tmux + if [ "$TRUE_FULL_SCREEN" == "fullscreen" ]; then + resize_to_true_full_screen + else + resize_window_to_full_screen + fi +} +main