From 6df79850cf58a64fb7c5904d6869e61ad8509888 Mon Sep 17 00:00:00 2001 From: Fernando Date: Fri, 2 Aug 2024 22:20:48 +1200 Subject: [PATCH 1/2] Added WezTerm support --- docs/automatic_start.md | 4 ++ .../handle_tmux_automatic_start/osx_enable.sh | 2 + .../osx_wezterm_start_tmux.sh | 68 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100755 scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh 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..8241936 --- /dev/null +++ b/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +# 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 From a90814767568934ead932695930e3cae52df5701 Mon Sep 17 00:00:00 2001 From: Fernando Date: Fri, 2 Aug 2024 22:26:47 +1200 Subject: [PATCH 2/2] Added name/handle at the top --- scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh b/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh index 8241936..2bf6c9e 100755 --- a/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh +++ b/scripts/handle_tmux_automatic_start/osx_wezterm_start_tmux.sh @@ -1,5 +1,8 @@ #!/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"