Skip to content

Commit

Permalink
Wezterm doesn't support OSC52 query, use alacritty
Browse files Browse the repository at this point in the history
  • Loading branch information
Jendker committed Oct 3, 2024
1 parent 3d48ee2 commit aa35a47
Show file tree
Hide file tree
Showing 5 changed files with 263 additions and 25 deletions.
91 changes: 91 additions & 0 deletions scripts/debian/alacritty.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
[font]
size = 11
normal = { family = "SFMono Nerd Font" }

[terminal]
osc52 = "CopyPaste"

[window]
padding = { x = 8, y = 5 }
opacity = 0.97
decorations = "None"

[shell]
program = "/usr/bin/zsh"

# Dracula theme for Alacritty
# https://draculatheme.com/alacritty
#
# Color palette
# https://spec.draculatheme.com
#
# Instructions
# https://github.com/alacritty/alacritty/blob/master/extra/man/alacritty.5.scd

[colors.primary]

background = "#282a36"
foreground = "#f8f8f2"
bright_foreground = "#ffffff"

[colors.cursor]

text = "#282a36"
cursor = "#f8f8f2"

[colors.vi_mode_cursor]

text = "CellBackground"
cursor = "CellForeground"

[colors.selection]

text = "CellForeground"
background = "#44475a"

[colors.normal]

black = "#21222c"
red = "#ff5555"
green = "#50fa7b"
yellow = "#f1fa8c"
blue = "#bd93f9"
magenta = "#ff79c6"
cyan = "#8be9fd"
white = "#f8f8f2"

[colors.bright]

black = "#6272a4"
red = "#ff6e6e"
green = "#69ff94"
yellow = "#ffffa5"
blue = "#d6acff"
magenta = "#ff92df"
cyan = "#a4ffff"
white = "#ffffff"

[colors.search.matches]

foreground = "#44475a"
background = "#50fa7b"

[colors.search.focused_match]

foreground = "#44475a"
background = "#ffb86c"

[colors.footer_bar]

background = "#282a36"
foreground = "#f8f8f2"

[colors.hints.start]

foreground = "#282a36"
background = "#f1fa8c"

[colors.hints.end]

foreground = "#f1fa8c"
background = "#282a36"
84 changes: 70 additions & 14 deletions scripts/debian/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ set -e
set -x

SCRIPT_DIR=$(dirname "$0")
ROOT_DIR=$(realpath "${SCRIPT_DIR}/../..")

source "$SCRIPT_DIR/common.sh"

# Initialize a flag
optional_provided=false
Expand Down Expand Up @@ -58,7 +59,7 @@ function setup_open_any_terminal() {
if [ "$DESKTOP_SESSION" != "ubuntu" ]; then
return
fi
# to open from nautilus with wezterm
# to open from nautilus with default terminal
# if /home/jorbik/.local/share/nautilus-python/extensions/nautilus_open_any_terminal.py does not exist
if [ ! -f ~/.local/share/nautilus-python/extensions/nautilus_open_any_terminal.py ]; then
cwd=$(pwd)
Expand All @@ -69,13 +70,26 @@ function setup_open_any_terminal() {
make

make install schema # User install
gsettings set com.github.stunkymonkey.nautilus-open-any-terminal terminal wezterm
gsettings set com.github.stunkymonkey.nautilus-open-any-terminal terminal alacritty
sudo apt install python3-nautilus -y
echo "To make the 'Open with Wezterm' work restart nautilus: 'nautilus -q'"
echo "To make the 'Open with <terminal>' work restart nautilus: 'nautilus -q'"
cd "$cwd"
fi
}

function setup_trdop() {
cwd=$(pwd)
mkdir -p ~/.local/bin/
cd ~/.local/bin/
git clone https://github.com/noctuid/tdrop.git
echo "Add custom hotkey in Ubuntu to activate terminal with tdrop"
echo "Command is: '$HOME/.local/bin/tdrop/tdrop -mta -h 100% <terminal_name>'"
echo "This will work work with nvidia drivers on the latest Ubuntu"
# installing tdrop dependencies
sudo apt install xdotool gawk -y
cd "$cwd"
}

function setup_wezterm() {
curl -fsSL https://apt.fury.io/wez/gpg.key | sudo gpg --yes --dearmor -o /usr/share/keyrings/wezterm-fury.gpg
echo 'deb [signed-by=/usr/share/keyrings/wezterm-fury.gpg] https://apt.fury.io/wez/ * *' | sudo tee /etc/apt/sources.list.d/wezterm.list
Expand All @@ -84,16 +98,57 @@ function setup_wezterm() {

if [ "$DESKTOP_SESSION" == "ubuntu" ] && [[ ! -e "$HOME/.local/bin/tdrop/tdrop" ]]; then
# ubuntu specific - set up tdrop for wezterm activation with hotkey
cwd=$(pwd)
mkdir -p ~/.local/bin/
cd ~/.local/bin/
git clone https://github.com/noctuid/tdrop.git
echo "Add custom hotkey in Ubuntu to activate wezterm with tdrop"
echo "Command is: '$HOME/.local/bin/tdrop/tdrop -mta -h 100% wezterm'"
echo "This will work work with nvidia drivers on the latest Ubuntu"
# installing tdrop dependencies
sudo apt install xdotool gawk -y
cd "$cwd"
setup_trdop
fi
}

function setup_alacritty_source() {
sudo apt install cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3 gzip scdoc -y
# install from source
install_rust
rustup override set stable
rustup update stable
cd /tmp
rm -rf alacritty
git clone https://github.com/alacritty/alacritty.git
cd alacritty

highest_tag=$(get_highest_tag_version)
git checkout "$highest_tag"

cargo build --release
# terminfo
infocmp alacritty || sudo tic -xe alacritty,alacritty-direct extra/alacritty.info
# desktop entry
sudo cp target/release/alacritty /usr/local/bin # or anywhere else in $PATH
sudo cp extra/logo/alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
sudo desktop-file-install extra/linux/Alacritty.desktop
sudo update-desktop-database
# manual page
sudo mkdir -p /usr/local/share/man/man1
sudo mkdir -p /usr/local/share/man/man5
scdoc < extra/man/alacritty.1.scd | gzip -c | sudo tee /usr/local/share/man/man1/alacritty.1.gz > /dev/null
scdoc < extra/man/alacritty-msg.1.scd | gzip -c | sudo tee /usr/local/share/man/man1/alacritty-msg.1.gz > /dev/null
scdoc < extra/man/alacritty.5.scd | gzip -c | sudo tee /usr/local/share/man/man5/alacritty.5.gz > /dev/null
scdoc < extra/man/alacritty-bindings.5.scd | gzip -c | sudo tee /usr/local/share/man/man5/alacritty-bindings.5.gz > /dev/null
# completion
mkdir -p ~/.zsh_functions
grep -qxF 'fpath+=~/.zsh_functions' "$HOME"/.zshrc || echo 'fpath+=~/.zsh_functions' >>"$HOME"/.zshrc
cp extra/completions/_alacritty ${ZDOTDIR:-~}/.zsh_functions/_alacritty
}

function setup_alacritty() {
if ! [ -x "$(command -v alacritty)" ]; then
sudo apt install alacritty -y || setup_alacritty_source
fi
if [ "$DESKTOP_SESSION" == "ubuntu" ]; then
# ubuntu specific - set up tdrop for wezterm activation with hotkey
if [[ ! -e "$HOME/.local/bin/tdrop/tdrop" ]]; then
setup_trdop
fi
echo "Consider running these to set the default terminal"
echo "sudo update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator /usr/bin/alacritty 50"
echo "sudo update-alternatives --config x-terminal-emulator"
fi
}

Expand All @@ -103,6 +158,7 @@ setup_sublimetext
setup_wezterm
setup_open_any_terminal
sudo apt install copyq -y
setup_alacritty

if [ "$DESKTOP_SESSION" == "ubuntu" ]; then
# disable meta+number key bindings - it interferes with wezterm
Expand Down
12 changes: 1 addition & 11 deletions scripts/debian/install_min.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ set -x

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

function get_highest_tag_version() {
git tag | sort -V | tail -n 1
}
source "$SCRIPT_DIR/common.sh"

function command_exists() {
command -v "$1" &>/dev/null
Expand Down Expand Up @@ -127,14 +125,6 @@ function update_git() {
fi
}

function install_rust() {
if ! [ -x "$(command -v cargo)" ]; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
grep -qxF 'source "$HOME/.cargo/env"' $HOME/.zshrc || echo 'source "$HOME/.cargo/env"' >>$HOME/.zshrc
echo "Please source ~/.zshrc or ~/.bashrc"
fi
}

function install_rust_tree_sitter() {
install_rust
$HOME/.cargo/bin/cargo install tree-sitter-cli
Expand Down
87 changes: 87 additions & 0 deletions scripts/macos/alacritty.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[font]
size = 13
normal = { family = "Monaco Nerd Font" }

[terminal]
osc52 = "CopyPaste"

[window]
padding = { x = 8, y = 5 }
opacity = 0.97

# Dracula theme for Alacritty
# https://draculatheme.com/alacritty
#
# Color palette
# https://spec.draculatheme.com
#
# Instructions
# https://github.com/alacritty/alacritty/blob/master/extra/man/alacritty.5.scd

[colors.primary]

background = "#282a36"
foreground = "#f8f8f2"
bright_foreground = "#ffffff"

[colors.cursor]

text = "#282a36"
cursor = "#f8f8f2"

[colors.vi_mode_cursor]

text = "CellBackground"
cursor = "CellForeground"

[colors.selection]

text = "CellForeground"
background = "#44475a"

[colors.normal]

black = "#21222c"
red = "#ff5555"
green = "#50fa7b"
yellow = "#f1fa8c"
blue = "#bd93f9"
magenta = "#ff79c6"
cyan = "#8be9fd"
white = "#f8f8f2"

[colors.bright]

black = "#6272a4"
red = "#ff6e6e"
green = "#69ff94"
yellow = "#ffffa5"
blue = "#d6acff"
magenta = "#ff92df"
cyan = "#a4ffff"
white = "#ffffff"

[colors.search.matches]

foreground = "#44475a"
background = "#50fa7b"

[colors.search.focused_match]

foreground = "#44475a"
background = "#ffb86c"

[colors.footer_bar]

background = "#282a36"
foreground = "#f8f8f2"

[colors.hints.start]

foreground = "#282a36"
background = "#f1fa8c"

[colors.hints.end]

foreground = "#f1fa8c"
background = "#282a36"
14 changes: 14 additions & 0 deletions scripts/set_up_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,17 @@ mkdir -p ~/.config/direnv
echo '[global]
load_dotenv = true
strict_env = true' >"$HOME"/.config/direnv/direnv.toml

alacritty_path=~/.config/alacritty/alacritty.toml
if [ ! -e $alacritty_path ]; then
mkdir -p ~/.config/alacritty
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
cp "${SCRIPT_DIR}/debian/alacritty.toml" $alacritty_path
elif [[ "$OSTYPE" == "darwin"* ]]; then
cp "${SCRIPT_DIR}/macos/alacritty.toml" $alacritty_path
else
echo "Unsupported OS"
exit 1
fi
cp
fi

0 comments on commit aa35a47

Please sign in to comment.