1
0
Fork 0
dotfiles/home/config/wezterm/config.fnl

262 lines
13 KiB
Text
Raw Normal View History

2022-12-21 18:02:41 +00:00
(let [wezterm (require :wezterm)
2023-01-18 19:18:12 +00:00
window-padding 15
2023-07-14 12:02:35 +00:00
colors {:frame-background "#282A36"
:active-background "#282A36"
2023-01-18 19:18:12 +00:00
:active-foreground "#ABB2BF"
:active-indicator "#BD93F9"
2023-07-14 12:02:35 +00:00
:inactive-background "#282A36"
2023-03-30 19:58:38 +00:00
:inactive-foreground "#6272A4"
2023-07-14 12:02:35 +00:00
:hover-background "#242530"
2023-03-30 19:58:38 +00:00
:hover-foreground "#191A21"
; Icons
:elixir "#A074C4"
2024-01-21 16:58:54 +00:00
:et "#1C3062"
2024-12-22 22:41:02 +00:00
:nvim "#019833"
2023-03-30 19:58:38 +00:00
:nix "#7EBAE4"
2023-07-14 19:07:55 +00:00
:reddit "#FA4400"
2024-12-29 21:34:05 +00:00
:ssh "#F4C82D"
:shell "#F8F8F2"}
enable-ligatures-flags [:calt=1 :clig=1 :liga=1]
disable-ligatures-flags [:calt=0 :clig=0 :liga=0]]
(var ligature-panes [])
(var latest-pane-update nil)
2023-01-18 19:18:12 +00:00
;; Event: Tab format
2023-07-14 19:07:55 +00:00
(fn extract-tab-title [tab]
(let [title tab.tab_title]
(if (and title (> (length title) 0)) title tab.active_pane.title)))
2024-12-23 00:07:17 +00:00
(fn extract-tab-info [title]
(match title
2024-12-29 21:34:05 +00:00
(where t (t:find "^nvim%s")) {:title (t:gsub "^nvim%s(.*)" "%1")
:icon " "
:color colors.nvim
:ignore-activity true}
(where t (t:find :^nvim$))
{: title :icon " " :color colors.nvim :ignore-activity true}
2024-12-23 00:07:17 +00:00
(where t (t:find "^git%s"))
{:title (t:gsub "^git%s(.*)" "%1") :icon "󰊢 " :color "#F25029"}
(where t (t:find "^mix%s"))
{:title (t:gsub "^mix%s(.*)" "%1") :icon " " :color colors.elixir}
(where t (t:find "^iex%s")) {: title :icon " " :color colors.elixir}
(where t (t:find "^upa%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^upp%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^nrsw%s")) {: title :icon " " :color colors.nix}
2024-12-25 22:30:55 +00:00
(where t (t:find :^nrsw$)) {: title :icon " " :color colors.nix}
2024-12-23 00:07:17 +00:00
(where t (t:find "^ngc%s")) {: title :icon " " :color colors.nix}
2024-12-25 22:30:55 +00:00
(where t (t:find :^ngc$)) {: title :icon " " :color colors.nix}
2024-12-23 00:07:17 +00:00
(where t (t:find "^nix%s")) {: title :icon " " :color colors.nix}
2024-12-30 22:22:20 +00:00
(where t (t:find "^nix%-%w+%s")) {: title :icon " " :color colors.nix}
2024-12-23 00:07:17 +00:00
(where t (t:find "^colmena%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^deploy%s")) {: title :icon " " :color colors.nix}
(where t (t:find "^ssh%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^scp%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^et%s")) {: title :icon " " :color colors.et}
(where t (t:find "^just%s")) {: title :icon " " :color "#C87D57"}
(where t (t:find :^ytdl)) {: title :icon " " :color "#FF0000"}
2024-12-30 22:22:20 +00:00
(where t (t:find "^instagram%-"))
2024-12-29 21:34:05 +00:00
{: title :icon " " :color "#FB2179" :ignore-activity true}
2024-12-30 22:22:20 +00:00
(where t (t:find "^gallery%-dl%s")) {:title (t:gsub "^gallery%-dl%s(.*)"
"%1")
:icon " "
:color "#009900"
:ignore-activity true}
(where t (t:find "^discord%-"))
2024-12-29 21:34:05 +00:00
{: title :icon " " :color "#5865F2" :ignore-activity true}
(where t (t:find "^bdfr%s")) {:title (t:gsub "^bdfr%s(.*)" "%1")
:icon " "
:color colors.reddit
:ignore-activity true}
2024-12-30 22:22:20 +00:00
(where t (t:find "^bdfr%-%w+%s"))
2024-12-29 21:34:05 +00:00
{: title :icon " " :color colors.reddit :ignore-activity true}
(where t (t:find "^rexit%s"))
{: title :icon " " :color colors.reddit :ignore-activity true}
2024-12-30 22:22:20 +00:00
(where t (t:find "^redis%-")) {: title :icon " " :color "#DC372C"}
2024-12-23 00:07:17 +00:00
(where t (t:find "^%[%w+%]%s")) {: title :icon " " :color colors.ssh}
(where t (t:find "^%w+@%w+:%s")) {: title :icon " " :color colors.ssh}
2024-12-30 22:22:20 +00:00
(where t (t:find "^%w+%-dev"))
2024-12-29 21:34:05 +00:00
{: title :icon " " :color "#0099CC" :ignore-activity true}
2024-12-30 22:22:20 +00:00
(where t (t:find "^%w+%-dl%s"))
2024-12-29 21:34:05 +00:00
{: title :icon " " :color "#22BC00" :ignore-activity true}
(where t (t:find "^~"))
{: title :icon " " :color colors.shell :ignore-activity true}
(where t (t:find :^zsh$))
{: title :icon "󰫫 " :color colors.shell :ignore-activity true}
2024-12-30 22:22:20 +00:00
(where t (t:find "^op%srun%s%-%-%s"))
(extract-tab-info (t:gsub "^op%srun%s%-%-%s(.*)" "%1"))
2024-12-29 21:34:05 +00:00
_ {: title :icon " " :color colors.shell}))
2023-01-18 19:18:12 +00:00
2024-12-29 19:43:58 +00:00
(fn show-tab-activity-indicator [panes]
(each [_ pane (ipairs panes)]
(when pane.has_unseen_output (lua "return true")))
false)
2023-01-18 19:18:12 +00:00
(wezterm.on :format-tab-title
2023-10-23 12:30:34 +00:00
(fn [tab _tabs _panes _config _hover max-width]
2023-07-14 19:07:55 +00:00
(let [raw-title (extract-tab-title tab)
2024-12-23 00:07:17 +00:00
tab-info (extract-tab-info raw-title)
2023-01-18 19:18:12 +00:00
title (wezterm.truncate_right tab-info.title
2024-12-29 19:43:58 +00:00
(- max-width 5))
2024-12-29 21:34:05 +00:00
(activity-indicator activity-color) (if (and (not tab-info.ignore-activity)
(show-tab-activity-indicator tab.panes))
2024-12-29 19:43:58 +00:00
(values "  "
"#FFB86C")
(values " " nil))]
2023-01-18 19:18:12 +00:00
(if tab.is_active
[; Left
{:Background {:Color colors.active-background}}
{:Foreground {:Color colors.active-indicator}}
2023-10-06 21:47:18 +00:00
{:Text "│ "}
2023-01-18 19:18:12 +00:00
; Center
{:Foreground {:Color tab-info.color}}
{:Text tab-info.icon}
{:Foreground {:Color colors.active-foreground}}
{:Attribute {:Intensity :Bold}}
{:Attribute {:Italic true}}
{:Text title}
; Right
2024-12-29 19:43:58 +00:00
{:Foreground {:Color (or activity-color
colors.active-foreground)}}
2023-01-18 19:18:12 +00:00
{:Attribute {:Intensity :Normal}}
{:Attribute {:Italic false}}
2024-12-29 19:43:58 +00:00
{:Text activity-indicator}]
2023-01-18 19:18:12 +00:00
[; Left
{:Background {:Color colors.inactive-background}}
{:Foreground {:Color colors.inactive-foreground}}
{:Text " "}
; Center
{:Foreground {:Color colors.inactive-foreground}}
2024-12-29 19:43:58 +00:00
{:Text tab-info.icon}
2023-07-14 12:02:35 +00:00
{:Attribute {:Italic false}}
2023-01-18 19:18:12 +00:00
{:Text title}
; Right
2024-12-29 19:43:58 +00:00
{:Foreground {:Color (or activity-color
colors.inactive-foreground)}}
{:Text activity-indicator}]))))
2023-10-23 12:30:34 +00:00
;; Event: Ligatures
(wezterm.on :update-status
(fn [window pane]
(local pane-id (pane:pane_id))
(when (not= latest-pane-update pane-id)
(let [overrides (or (window:get_config_overrides) {})]
(set latest-pane-update pane-id)
(if (. ligature-panes pane-id)
(do
(set overrides.harfbuzz_features
enable-ligatures-flags)
(window:set_config_overrides overrides))
(do
(set overrides.harfbuzz_features
disable-ligatures-flags)
(window:set_config_overrides overrides)))))))
(wezterm.on :user-var-changed
(fn [window pane name value]
(let [overrides (or (window:get_config_overrides) {})
pane-id (pane:pane_id)]
(case [name value]
[:enable-ligatures :t] (do
(set overrides.harfbuzz_features
enable-ligatures-flags)
(tset ligature-panes pane-id true)
(window:set_config_overrides overrides))
[:enable-ligatures :f] (do
(set overrides.harfbuzz_features
disable-ligatures-flags)
(tset ligature-panes pane-id nil)
(window:set_config_overrides overrides))))))
2023-10-23 12:30:34 +00:00
;; Event: Screen options
(wezterm.on :window-resized
(fn [window _pane]
(let [overrides (or (window:get_config_overrides) {})
current-screen (. (wezterm.gui.screens) :active :name)]
(case current-screen
:S34J55x (do
(set overrides.line_height 1)
(set overrides.freetype_load_target :Normal)
(window:set_config_overrides overrides))
_ (do
(set overrides.line_height 0.95)
(set overrides.freetype_load_target :Light)
(window:set_config_overrides overrides))))))
2023-01-18 19:18:12 +00:00
;; Configuration
2024-12-23 00:07:17 +00:00
{:term :wezterm
:default_prog [_G.shells.zsh :-i]
2022-12-19 21:02:48 +00:00
;; Appearance
:color_scheme "Dracula (Official)"
2023-07-14 12:02:35 +00:00
:window_decorations :INTEGRATED_BUTTONS|RESIZE
2022-12-21 18:02:41 +00:00
:window_padding {:left window-padding
:right window-padding
2023-07-14 12:02:35 +00:00
:top (math.floor (/ window-padding 2))
:bottom (math.floor (/ window-padding 2))}
2023-01-18 19:18:12 +00:00
;; Tabs
2022-12-19 21:02:48 +00:00
:enable_tab_bar true
2023-07-14 12:02:35 +00:00
:use_fancy_tab_bar true
:hide_tab_bar_if_only_one_tab false
:tab_bar_at_bottom false
2023-07-14 19:07:55 +00:00
:tab_max_width 42
2023-07-14 12:02:35 +00:00
:window_frame {:active_titlebar_bg colors.frame-background
:inactive_titlebar_bg colors.frame-background
2025-01-02 16:24:32 +00:00
:font (wezterm.font {:family :TX-02
2023-10-06 21:47:18 +00:00
:weight :Regular
:harfbuzz_features disable-ligatures-flags})
2023-07-14 12:02:35 +00:00
:font_size 11}
:colors {:tab_bar {:background colors.frame-background
:inactive_tab_edge colors.frame-background
2023-01-18 19:18:12 +00:00
:new_tab {:bg_color colors.inactive-background
2023-07-14 12:02:35 +00:00
:fg_color colors.inactive-foreground}
2023-03-30 19:58:38 +00:00
:new_tab_hover {:bg_color colors.hover-background
2023-07-14 12:02:35 +00:00
:fg_color colors.hover-foreground}}}
2022-12-19 21:02:48 +00:00
;; Fonts
2025-01-02 16:24:32 +00:00
:font (wezterm.font_with_fallback [:TX-02
2022-12-19 21:02:48 +00:00
"Symbols Nerd Font"
"Apple Symbols"
"Apple Color Emoji"
"Noto Sans Symbols"
2023-10-20 19:53:30 +00:00
"Noto Sans Symbols 2"])
2022-12-19 21:02:48 +00:00
:font_size 13
2023-10-08 10:49:01 +00:00
:line_height 0.95
2022-12-19 21:02:48 +00:00
:freetype_load_target :Light
;:freetype_render_target :HorizontalLcd
:harfbuzz_features disable-ligatures-flags
2022-12-20 16:46:51 +00:00
:allow_square_glyphs_to_overflow_width :WhenFollowedBySpace
2024-06-19 08:10:24 +00:00
:adjust_window_size_when_changing_font_size false
2022-12-20 16:46:51 +00:00
;; Keys
:keys [{:key :UpArrow
:mods :SHIFT
:action (wezterm.action.ScrollToPrompt -1)}
{:key :DownArrow
:mods :SHIFT
2023-01-22 12:47:36 +00:00
:action (wezterm.action.ScrollToPrompt 1)}
{:key :LeftArrow
:mods :CMD
:action (wezterm.action.ActivateTabRelative -1)}
{:key :RightArrow
:mods :CMD
:action (wezterm.action.ActivateTabRelative 1)}]
2025-01-02 19:27:44 +00:00
:enable_kitty_keyboard true
2023-02-06 10:47:54 +00:00
:send_composed_key_when_left_alt_is_pressed true
:send_composed_key_when_right_alt_is_pressed true
2022-12-19 21:02:48 +00:00
;; Mouse
:mouse_bindings [; Only select text and don't open hyperlinks
{:event {:Up {:streak 1 :button :Left}}
:mods :NONE
:action (wezterm.action {:ExtendSelectionToMouseCursor :Cell})}
2022-12-20 16:46:51 +00:00
; Only select word on double click
2022-12-19 21:02:48 +00:00
{:event {:Up {:streak 2 :button :Left}}
:mods :NONE
2022-12-20 16:46:51 +00:00
:action (wezterm.action.SelectTextAtMouseCursor :Word)}
; Select entire output of command
{:event {:Down {:streak 3 :button :Left}}
:mods :NONE
:action (wezterm.action.SelectTextAtMouseCursor :SemanticZone)}
2022-12-19 21:02:48 +00:00
; CMD-click to open a hyperlink
{:event {:Up {:streak 1 :button :Left}}
2022-12-20 16:46:51 +00:00
:mods :SUPER
2022-12-19 21:02:48 +00:00
:action :OpenLinkAtMouseCursor}]
;; Scrollback
2022-12-20 16:46:51 +00:00
:scrollback_lines 5000
;; Other
2023-07-14 19:07:55 +00:00
:front_end :WebGpu
2025-01-02 19:27:44 +00:00
:max_fps 120
2022-12-20 16:46:51 +00:00
:check_for_updates false})