From 154e386bbe2c74b2c2b1cde9d06a9ca9e41be5d6 Mon Sep 17 00:00:00 2001 From: Chris Minton Date: Tue, 1 Dec 2020 00:00:06 +0000 Subject: [PATCH] feat: add alacritty to the list of auto start terminals --- docs/automatic_start.md | 3 + .../osx_alacritty_start_tmux.sh | 70 +++++++++++++++++++ .../handle_tmux_automatic_start/osx_enable.sh | 2 + 3 files changed, 75 insertions(+) create mode 100755 scripts/handle_tmux_automatic_start/osx_alacritty_start_tmux.sh diff --git a/docs/automatic_start.md b/docs/automatic_start.md index 58882f0..19c0c15 100644 --- a/docs/automatic_start.md +++ b/docs/automatic_start.md @@ -24,6 +24,9 @@ Config options: of `Terminal.app` - `set -g @continuum-boot-options 'kitty,fullscreen'` - start `kitty` in fullscreen +- `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 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_alacritty_start_tmux.sh b/scripts/handle_tmux_automatic_start/osx_alacritty_start_tmux.sh new file mode 100755 index 0000000..54821f9 --- /dev/null +++ b/scripts/handle_tmux_automatic_start/osx_alacritty_start_tmux.sh @@ -0,0 +1,70 @@ +#!/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 "alacritty" + activate + delay 0.5 + tell application "System Events" to tell process "alacritty" + set frontmost to true + keystroke "tmux" + key code 36 + end tell + end tell + EOF +} + +resize_window_to_full_screen() { + osascript <<-EOF + tell application "alacritty" + activate + tell application "System Events" + if (every window of process "alacritty") 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 "alacritty" to {0, 0} + set size of front window of process "alacritty" to {item 3 of desktopSize, item 4 of desktopSize} + end tell + end tell + EOF +} + +resize_to_true_full_screen() { + osascript <<-EOF + tell application "Alacritty" + activate + delay 0.5 + tell application "System Events" to tell process "Alacritty" + 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 + +resize_to_ \ No newline at end of file diff --git a/scripts/handle_tmux_automatic_start/osx_enable.sh b/scripts/handle_tmux_automatic_start/osx_enable.sh index 1fd3f60..38e6537 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" =~ "alacritty" ]]; then + echo "alacritty" else # Terminal.app is the default console app echo "terminal"