feat(nix): migrate WezTerm

This commit is contained in:
Stefan Imhoff
2024-07-18 17:44:43 +02:00
parent 412f4dea86
commit 4606d1cb9c
7 changed files with 44 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ in
./ruby
./sesh
./skhd
./wezterm
./wget
./yabai
./yazi
@@ -36,6 +37,37 @@ in
config = {
home.stateVersion = "23.05";
home.activation = {
# Install terminfo for wezterm
installWeztermProfile = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
tempfile=$(mktemp) \
&& ${pkgs.curl}/bin/curl -o $tempfile https://raw.githubusercontent.com/wez/wezterm/main/termwiz/data/wezterm.terminfo \
&& tic -x -o ~/.terminfo $tempfile \
&& rm $tempfile
'';
# Install custom icon for WezTerm
setupWezTermCustomIcon = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
icon_path="$HOME/.config/wezterm/terminal.icns"
app_path="/Applications/WezTerm.app"
$DRY_RUN_CMD mkdir -p "$(dirname "$icon_path")"
$DRY_RUN_CMD cp -f ${./wezterm/wezterm.icns} "$icon_path"
if [ -d "$app_path" ]; then
$DRY_RUN_CMD cp "$icon_path" "$app_path"/Contents/Resources/terminal.icns
# Touch the app to refresh Finder
$DRY_RUN_CMD touch "$app_path"
$DRY_RUN_CMD ${pkgs.darwin.xattr}/bin/xattr -rc "$app_path"
$VERBOSE_ECHO "Applied custom icon to WezTerm.app"
$DRY_RUN_CMD touch "$app_path"
else
$VERBOSE_ECHO "WezTerm.app not found in /Applications. Custom icon not applied."
fi
'';
};
# Let Home Manager install and manage itself.
programs.home-manager.enable = true;
@@ -51,6 +83,7 @@ in
comma # Comma runs software without installing it
nixd # Nix language server
nixpkgs-fmt # Nix code formatter
darwin.xattr # Display and manipulate extended attributes
];
};
}

View File

@@ -0,0 +1,10 @@
{ pkgs, ... }:
{
programs.wezterm = {
enable = true;
extraConfig = builtins.readFile ./wezterm.lua;
};
home.packages = [ pkgs.wezterm ];
}

Binary file not shown.

View File

@@ -0,0 +1,134 @@
local wezterm = require("wezterm")
local config = {}
if wezterm.config_builder then
config = wezterm.config_builder()
end
-- Colorscheme and font
config.font = wezterm.font_with_fallback({
{
family = "Monaspace Neon",
harfbuzz_features = { "calt=1", "clig=1", "liga=1", "dlig=1", "ss01=1", "ss02=1", "ss03=1", "ss04=1", "ss05=1", "ss06=1", "ss07=1", "ss08=1" },
weight = "Regular",
italic = false,
},
"Symbols Nerd Font Mono",
"Noto Color Emoji",
"Noto Emoji",
})
config.font_rules = {
-- Comment in code (italic)
{
intensity = "Normal",
italic = true,
font = wezterm.font_with_fallback({
{
family = "Monaspace Radon",
weight = "ExtraLight",
stretch = "Normal",
style = "Normal",
harfbuzz_features = { "calt=1", "liga=1", "dlig=1", "ss01=1", "ss02=1", "ss03=1", "ss04=1", "ss05=1", "ss06=1", "ss07=0", "ss08=1" },
},
}),
},
-- Highlighted text in code (bold)
{
intensity = "Bold",
italic = false,
font = wezterm.font_with_fallback({
{
family = "Monaspace Krypton",
weight = "Light",
stretch = "Normal",
style = "Normal",
harfbuzz_features = { "calt=1", "liga=1", "dlig=1", "ss01=1", "ss02=1", "ss03=1", "ss04=1", "ss05=1", "ss06=1", "ss07=0", "ss08=1" },
},
}),
},
-- Bold-italic
{
intensity = "Bold",
italic = true,
font = wezterm.font_with_fallback({
{
family = "Monaspace Radon",
weight = "Light",
stretch = "Normal",
style = "Normal",
harfbuzz_features = { "calt=1", "liga=1", "dlig=1", "ss01=1", "ss02=1", "ss03=1", "ss04=1", "ss05=1", "ss06=1", "ss07=0", "ss08=1" },
},
}),
},
}
config.font_size = 22.0
config.line_height = 1.2
config.color_scheme = "Catppuccin Mocha"
config.cursor_blink_rate = 0
config.audible_bell = "Disabled"
-- Tokyo Night color scheme (custom adjustments)
config.colors = {
cursor_bg = "#f8f8f0",
cursor_fg = "#000000",
selection_bg = "#373b41",
selection_fg = "#ffffff",
ansi = { "#1f1f1f", "#f92672", "#a6e22e", "#fd971f", "#66d9ef", "#ae81ff", "#a1efe4", "#f8f8f2" },
brights = { "#75715e", "#f92672", "#a6e22e", "#fd971f", "#66d9ef", "#ae81ff", "#a1efe4", "#f9f8f5" },
}
config.front_end = "WebGpu"
-- Window
config.window_decorations = "RESIZE|MACOS_FORCE_ENABLE_SHADOW"
config.window_background_opacity = 0.9
config.initial_cols = 100
config.initial_rows = 65
config.enable_tab_bar = false
config.macos_window_background_blur = 30
config.hide_tab_bar_if_only_one_tab = true
config.window_padding = {
left = 30,
right = 30,
top = 30,
bottom = 30,
}
-- Custom Keybindings
config.keys = {
{ key = ",", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2v" }) }, -- Rename window
{ key = "1", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\21" }) }, -- window 1
{ key = "2", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\22" }) }, -- window 2
{ key = "3", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\23" }) }, -- window 3
{ key = "4", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\24" }) }, -- window 4
{ key = "5", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\25" }) }, -- window 5
{ key = "6", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\26" }) }, -- window 6
{ key = "7", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\27" }) }, -- window 7
{ key = "8", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\28" }) }, -- window 8
{ key = "9", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\29" }) }, -- window 9
{ key = ";", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2:" }) }, -- Command Mode
{ key = "Enter", mods = "CMD", action = wezterm.action.ToggleFullScreen }, -- Toggle fullscreen
{ key = "[", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2p" }) }, -- Previous window
{ key = "]", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2n" }) }, -- Next window
{ key = "d", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2D" }) }, -- Lazydocker
{ key = "d", mods = "CTRL|ALT|SHIFT", action = wezterm.action({ SendString = "\2d" }) }, -- Detach session
{ key = "f", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2O" }) }, -- LF
{ key = "g", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2G" }) }, -- Lazygit
{ key = "h", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2p" }) }, -- Previous window
{ key = "i", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2i" }) }, -- Cht.sh
{ key = "j", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2s" }) }, -- Select windows
{ key = "k", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2s" }) }, -- Select windows
{ key = "l", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2n" }) }, -- Next window
{ key = "p", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2\84" }) }, -- Smart tmux session manager
{ key = "q", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2d" }) }, -- Detach session
{ key = "r", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2R" }) }, -- Return to last session
{ key = "t", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2c" }) }, -- New window
{ key = "w", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2x" }) }, -- Close window
{ key = "y", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2W" }) }, -- Yazi
{ key = "z", mods = "CTRL|ALT", action = wezterm.action({ SendString = "\2z" }) }, -- Zoom into window
}
return config