diff --git a/wezterm/wezterm.lua b/wezterm/wezterm.lua new file mode 100644 index 0000000..9cbc8aa --- /dev/null +++ b/wezterm/wezterm.lua @@ -0,0 +1,153 @@ +-- Ctrl+Shift+R to force config reload +-- Ctrl+Shift+L to enter WezTerm REPL/Console +-- Ctrl+Shift+P to bring up WezTerm command palette +-- wezterm.log_info("debug") + +local wezterm = require("wezterm") +local config = wezterm.config_builder() + +config.initial_cols = 150 +config.initial_rows = 48 + +config.hide_tab_bar_if_only_one_tab = true +config.tab_bar_at_bottom = true +config.use_fancy_tab_bar = false +config.show_new_tab_button_in_tab_bar = false +config.enable_scroll_bar = true +config.window_background_opacity = 0.8 +config.window_padding = { + left = 0, + right = 0, + top = 0, + bottom = 0, +} +config.use_resize_increments = true + +config.colors = { + foreground = "#ffffff", + background = "#000000", + cursor_fg = "#000000", + cursor_bg = "#ffffff", + cursor_border = "#ffffff", + ansi = { + "#171421", -- black + "#c01c28", -- red + "#26a269", -- green + "#a2734c", -- yellow + "#12488b", -- blue + "#a347ba", -- magenta + "#2aa1b3", -- cyan + "#d0cfcc", -- white + }, + brights = { + "#5e5c64", -- black + "#f66151", -- red + "#33d17a", -- green + "#e9ad0c", -- yellow + "#2a7bde", -- blue + "#c061cb", -- magenta + "#33c7de", -- cyan + "#ffffff", -- white + }, +} +-- config.color_scheme = "Gnometerm (terminal.sexy)" + +config.font = wezterm.font({ + family = "Cascadia Mono", + harfbuzz_features = { "calt=0", "clig=0", "liga=0" }, +}) +config.font_size = 12 +config.line_height = 1.0 +config.freetype_load_target = "Light" + +-------------------------------------------------------------------------------- +-- borrowed from: https://github.com/protiumx/.dotfiles/blob/main/stow/wezterm/.config/wezterm/wezterm.lua + +-- wezterm.nerdfonts reference: https://wezfurlong.org/wezterm/config/lua/wezterm/nerdfonts.html +local process_icons = { + ["bash"] = wezterm.nerdfonts.cod_terminal_bash, + ["cargo"] = wezterm.nerdfonts.dev_rust, + ["clj"] = wezterm.nerdfonts.dev_clojure, + ["clojure"] = wezterm.nerdfonts.dev_clojure, + ["curl"] = wezterm.nerdfonts.mdi_flattr, + ["docker"] = wezterm.nerdfonts.linux_docker, + ["docker-compose"] = wezterm.nerdfonts.linux_docker, + ["git"] = wezterm.nerdfonts.dev_git, + ["go"] = wezterm.nerdfonts.seti_go, + ["htop"] = wezterm.nerdfonts.md_chart_bar, + ["java"] = wezterm.nerdfonts.dev_java, + ["kubectl"] = wezterm.nerdfonts.linux_docker, + ["lein"] = wezterm.nerdfonts.dev_clojure, + ["lua"] = wezterm.nerdfonts.seti_lua, + ["make"] = wezterm.nerdfonts.seti_makefile, + ["nano"] = wezterm.nerdfonts.md_file_edit, + ["node"] = wezterm.nerdfonts.mdi_hexagon, + ["nvim"] = wezterm.nerdfonts.custom_neovim, + ["psql"] = "󱤢", + ["python3"] = "", + ["Python"] = "", + ["ruby"] = wezterm.nerdfonts.cod_ruby, + ["ssh"] = wezterm.nerdfonts.md_ssh, + ["ssh-add"] = wezterm.nerdfonts.md_ssh, + ["stern"] = wezterm.nerdfonts.linux_docker, + ["sudo"] = wezterm.nerdfonts.fa_hashtag, + ["vim"] = wezterm.nerdfonts.dev_vim, + ["wget"] = wezterm.nerdfonts.mdi_arrow_down_box, +} + +local function get_current_working_dir(tab) + local current_dir = tab.active_pane and tab.active_pane.current_working_dir or { file_path = "" } + local HOME_DIR = os.getenv("HOME") + + return current_dir.file_path == HOME_DIR and "~" or string.gsub(current_dir.file_path, "(.*[/\\])(.*)", "%2") +end + +local function get_process(tab) + if not tab.active_pane or tab.active_pane.foreground_process_name == "" then + return nil + end + + local process_name = string.gsub(tab.active_pane.foreground_process_name, "(.*[/\\])(.*)", "%2") + if string.find(process_name, "kubectl") then + process_name = "kubectl" + end + + return process_icons[process_name] or string.format("[%s]", process_name) +end + +local SOLID_LEFT_ARROW = wezterm.nerdfonts.pl_right_hard_divider +local SOLID_RIGHT_ARROW = wezterm.nerdfonts.pl_left_hard_divider + +wezterm.on("format-tab-title", function(tab, tabs, panes, config, hover, max_width) + local has_unseen_output = false + if not tab.is_active then + for _, pane in ipairs(tab.panes) do + if pane.has_unseen_output then + has_unseen_output = true + break + end + end + end + + local cwd = wezterm.format({ + { Text = get_current_working_dir(tab) }, + }) + + local process = get_process(tab) + local title = process and string.format(" %s (%s) ", process, cwd) or " [?] " + + if has_unseen_output then + return { + { Foreground = { Color = "#ffffff" } }, + { Text = title }, + } + end + + return { + { Text = title }, + } +end) + +-------------------------------------------------------------------------------- + +return config