dotfiles
at main 163 lines 5.1 kB view raw
1local wezterm = require 'wezterm' 2 3-- find from: https://github.com/thanhvule0310/dotfiles/blob/main/config/wezterm/wezterm.lua 4local function get_process(tab) 5 local process_icons = { 6 ["fish"] = { 7 { Text = wezterm.nerdfonts.mdi_fish }, 8 }, 9 ["docker"] = { 10 { Text = wezterm.nerdfonts.linux_docker }, 11 }, 12 ["nvim"] = { 13 { Text = wezterm.nerdfonts.custom_vim }, 14 }, 15 ["vim"] = { 16 { Text = wezterm.nerdfonts.dev_vim }, 17 }, 18 ["node"] = { 19 { Text = wezterm.nerdfonts.mdi_hexagon }, 20 }, 21 ["go"] = { 22 { Text = wezterm.nerdfonts.mdi_language_go }, 23 }, 24 ["cargo"] = { 25 { Text = wezterm.nerdfonts.dev_rust }, 26 }, 27 ["lua"] = { 28 { Text = wezterm.nerdfonts.seti_lua }, 29 }, 30 ["wget"] = { 31 { Text = wezterm.nerdfonts.mdi_arrow_down_box }, 32 }, 33 ["curl"] = { 34 { Text = wezterm.nerdfonts.mdi_flattr }, 35 }, 36 ['lazygit'] = { 37 { Text = wezterm.nerdfonts.dev_git }, 38 }, 39 } 40 41 local process_name = string.gsub(tab.active_pane.foreground_process_name, "(.*[/\\])(.*)", "%2") 42 if process_name == '' then 43 process_name = '?' 44 end 45 46 return wezterm.format(process_icons[process_name] 47 or { 48 { Text = string.format('[%s]', process_name) } 49 }) 50end 51 52local function get_current_working_dir(tab) 53 local current_dir = tab.active_pane.current_working_dir 54 local HOME_DIR = string.format("file://%s", os.getenv("HOME")) 55 return current_dir == HOME_DIR and "  ~" 56 or string.format("  %s", string.gsub(current_dir, "(.*[/\\])(.*)", "%2")) 57end 58 59wezterm.on( 60 'format-tab-title', 61 function(tab, _tabs, _panes, _config, hover, _max_width) 62 local background = '#1b1032' 63 local foreground = '#c0c0c0' 64 if tab.is_active then 65 local tmp = background 66 background = foreground 67 foreground = tmp 68 elseif hover then 69 background = '#3b3052' 70 foreground = '#909090' 71 end 72 73 return wezterm.format({ 74 { Foreground = { Color = foreground } }, 75 { Background = { Color = background } }, 76 { Text = string.format(' %s ', tab.tab_index + 1) }, 77 { Text = get_process(tab) }, 78 { Text = " " }, 79 { Text = get_current_working_dir(tab) }, 80 { Text = '' }, 81 }) 82 end 83) 84 85local lineheight = 1.2 86 87return { 88 font = wezterm.font_with_fallback { 89 'Fira Code', 90 'Menlo', 91 'Sarasa Mono K', 92 'Noto Color Emoji', 93 -- 'codicon', 94 'Symbols Nerd Font Mono', 95 }, 96 font_rules = { 97 { 98 italic = true, 99 intensity = 'Normal', 100 font = wezterm.font { 101 -- other cursive fonts : Operator Mono, Cascadia Mono, Victor Mono, Dank Mono 102 family = 'Cascadia Code', 103 harfbuzz_features = { 'ss01=1' }, 104 weight = 'DemiLight', 105 style = 'Italic', 106 }, 107 }, 108 { 109 italic = true, 110 intensity = 'Bold', 111 font = wezterm.font { 112 family = 'Cascadia Code', 113 harfbuzz_features = { 'ss01=1' }, 114 weight = 'Bold', 115 style = 'Italic', 116 }, 117 }, 118 }, 119 line_height = lineheight, 120 allow_square_glyphs_to_overflow_width = "Always", 121 hide_tab_bar_if_only_one_tab = true, 122 use_fancy_tab_bar = false, 123 tab_bar_at_bottom = true, 124 tab_max_width = 50, 125 adjust_window_size_when_changing_font_size = false, 126 -- window_background_opacity = 0.9, 127 macos_window_background_blur = 20, 128 -- window_decorations = "RESIZE", 129 window_padding = { 130 top = 0, 131 bottom = 0, 132 left = 0, 133 right = 0, 134 }, 135 use_resize_increments = false, 136 font_size = 12.0, 137 -- set underline at bottom position based on lineheight 138 -- NOTE: subtract 150 to prevent undercurl cutoff 139 underline_position = ((lineheight - 1) * 1000 + 300) - 150 .. '%', 140 underline_thickness = "1.5pt", 141 cursor_thickness = "1pt", 142 -- TODO: import colorscheme from Neovim 143 color_scheme = 'Kanagawa (Gogh)', 144 disable_default_key_bindings = false, 145 enable_csi_u_key_encoding = false, 146 enable_kitty_keyboard = true, 147 enable_kitty_graphics = true, 148 keys = { 149 { key = 'Tab', mods = 'CTRL', action = wezterm.action.DisableDefaultAssignment }, 150 { key = 'Tab', mods = 'CTRL|SHIFT', action = wezterm.action.DisableDefaultAssignment }, 151 { key = 's', mods = 'CMD', action = wezterm.action.SendKey { key = 's', mods = 'ALT' } }, 152 -- { key = '1', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 153 -- { key = '2', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 154 -- { key = '3', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 155 -- { key = '4', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 156 -- { key = '5', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 157 -- { key = '6', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 158 -- { key = '7', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 159 -- { key = '8', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 160 -- { key = '9', mods = 'CMD', action = wezterm.action.DisableDefaultAssignment }, 161 }, 162 use_ime = true, 163}