repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

wezterm: vendored in workspace_switcher wezterm: codefonts on keybind instead on startup now wezterm: fix status colors

bf804874b8d47849eba004c7b184e4970e2e6972

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (15)

helix/config.toml

Modified
1 -theme = "nugu-dark"
1 +theme = "nugu-light"
3 3 [editor]
4 4 shell = ["nu", "--commands"]

wezterm/bugabinga/code_font.lua

Modified
6 6 if code_fonts then
7 7 local new_lines = {}
8 8 for line in code_fonts:lines() do
9 - local weight, font_name = line:match(csv_line_pattern)
9 + local weight, font_name = line:match( csv_line_pattern )
10 10 if not weight or not font_name then
11 11 wez.log_error 'Could not parse code_fonts.csv. Borked?'
12 12 return
74 74 local selected = 'JetBrains Mono' -- safe default, because built in to wezterm
75 75 local font_names = {}
76 76 local weights = {}
77 - local total_weight = 1 -- to account for luas 1 based indexing
77 + local total_weight = 1 -- to account for luas 1 based indexing
78 78 local code_fonts = io.open( wez.config_dir .. '/bugabinga/code_fonts.csv', 'r' )
80 80 if code_fonts then
81 81 for line in code_fonts:lines() do
82 - local weight, font_name = line:match(csv_line_pattern)
82 + local weight, font_name = line:match( csv_line_pattern )
83 83 if not weight or not font_name then
84 84 wez.log_error 'Could not parse code_fonts.csv. Borked?'
85 85 break

wezterm/bugabinga/code_fonts.csv

Modified
1 -10,Bitstream Vera Sans Mono
2 -11,Lekton
3 -14,M+ 2m
4 -18,IBM Plex Mono
5 -20,Generic Mono II
6 -20,Hermit
7 -22,Monaspace Krypton Var
8 -3,Luculent
9 -4,Envy Code R
10 -4,SmallTypeWriting
11 -54,M+ 1mn
12 -6,Oxygen Mono
13 -7,Kawkab Mono
1 +15,M+ 2m
2 +50,IBM Plex Mono
3 +21,Generic Mono II
4 +20,Hermit
5 +17,Oxygen Mono

wezterm/bugabinga/dotfiles_workspace.lua

Modified
18 18 size = 0.42,
19 19 args = { 'nvim', 'wezterm', '-c', 'lua vim.api.nvim_set_current_dir("' .. dotfiles_path .. '/wezterm' .. '")', },
21 - neovim_pane:activate()
21 + command_pane:activate()
22 22 wez.mux.set_active_workspace 'dotfiles'
23 23 window:gui_window():maximize()
24 24 end )

wezterm/bugabinga/fonts.lua

Modified
1 1 local wez = require 'wezterm'
2 +local codefont = require 'bugabinga.code_font'
4 +wez.on( 'inc-font-size', function ( window )
5 + local size = window:effective_config().font_size + 1
6 + local overrides = window:get_config_overrides() or {}
7 + overrides.font_size = size
8 + window:set_config_overrides( overrides )
9 +end )
11 +wez.on( 'dec-font-size', function ( window )
12 + local size = window:effective_config().font_size - 1
13 + local overrides = window:get_config_overrides() or {}
14 + overrides.font_size = size
15 + window:set_config_overrides( overrides )
16 +end )
18 +wez.on( 'reset-font-size', function ( window )
19 + local size = nil
20 + local overrides = window:get_config_overrides() or {}
21 + overrides.font_size = size
22 + window:set_config_overrides( overrides )
23 +end )
25 +wez.on( 'random-codefont', function ( window )
26 + local random_font = codefont.random()
27 + local overrides = window:get_config_overrides() or {}
28 + overrides.font = random_font
29 + window:set_config_overrides( overrides )
30 +end )
32 +wez.on( 'change-font-size', function ( window, pane )
33 + local font_sizes = {}
34 + for size = 8, 32 do
35 + table.insert( font_sizes, { id = tostring( size ), label = ' ' .. size, } )
36 + end
38 + window:perform_action(
39 + wez.action.InputSelector {
40 + action = wez.action_callback( function ( win, _, id, label )
41 + if not id and not label then
42 + window:toast_notification( 'font', 'Cancelled font size selection!', nil, 500 )
43 + return
44 + end
45 + local overrides = win:get_config_overrides() or {}
46 + overrides.font_size = tonumber( id )
47 + window:set_config_overrides( overrides )
48 + window:toast_notification( 'font', 'Font set to size ' .. label, nil, 500 )
49 + end ),
50 + title = 'Select font size',
51 + choices = font_sizes,
52 + alphabet = '1234567890',
53 + description = 'Pick the font size to apply to wezterm.',
54 + fuzzy = true,
55 + }, pane )
56 +end )
3 58 return function ( cfg )
4 59 local font_size = 16.0

wezterm/bugabinga/hosts/NB-00718.lua

Modified
1 -local code_font = require 'bugabinga.code_font'
1 +local wez = require 'wezterm'
3 3 return function ( cfg )
4 4 cfg.font_size = 15
5 - cfg.font = code_font.random();
5 + cfg.font = wez.font 'Generic Mono II'
7 7 cfg.window_decorations = 'RESIZE'
8 8 end

wezterm/bugabinga/hosts/fedora.lua

Modified
1 -local code_font = require 'bugabinga.code_font'
1 +local wez = require 'wezterm'
3 2 return function ( cfg )
4 3 cfg.window_decorations = 'NONE'
5 - cfg.font = code_font.random();
4 + cfg.font = wez.font 'IBM Plex Mono';
6 5 end

wezterm/bugabinga/hosts/x230.lua

Modified
1 -local code_font = require 'bugabinga.code_font'
1 +local wez = require'wezterm'
3 3 return function ( cfg )
4 4 cfg.window_decorations = 'NONE'
5 5 cfg.font_size = 11
6 - cfg.font = code_font.random();
7 -<<<<<<< HEAD
8 -||||||| parent of 3a7673c (wezterm: adjust to more readable colors)
6 + cfg.font = wez.font 'M+ 2m'
9 7 end

wezterm/bugabinga/key_binds.lua

Modified
1 1 local wez = require 'wezterm'
2 --- FIXME: vendor in custom version of this plugin
3 -local workspace_switcher = wez.plugin.require 'https://github.com/MLFlexer/smart_workspace_switcher.wezterm'
2 +local workspace_switcher = require 'bugabinga.workspace_switcher'
5 4 local custom_action = function ( _ )
6 5 local id = 'custom-action-' .. tostring( wez.time.now() )
12 11 if wez.target_triple:find 'windows' then
13 12 leader = { key = 'raw:255', }
15 -local font_mode = ' Font mode (-=🠙🠛␡)'
14 +local font_mode = ' Font mode (-=0🠙🠛␡⎆ 󱁐 )'
16 15 local pane_mode = ' Pane (hjklqr)'
17 16 local resize_pane_mode = 'ﭕ Resize Pane (hjkl)'
19 -wez.on( 'inc-font-size', function ( window )
20 - local size = window:effective_config().font_size + 1
21 - local overrides = window:get_config_overrides() or {}
22 - overrides.font_size = size
23 - window:set_config_overrides( overrides )
24 -end )
26 -wez.on( 'dec-font-size', function ( window )
27 - local size = window:effective_config().font_size - 1
28 - local overrides = window:get_config_overrides() or {}
29 - overrides.font_size = size
30 - window:set_config_overrides( overrides )
31 -end )
33 18 local key_tables = {
34 19 [resize_pane_mode] = {
35 20 { key = 'h', action = wez.action.AdjustPaneSize { 'Left', 1, }, },
43 28 [font_mode] = {
44 29 { key = '-', action = wez.action.EmitEvent 'dec-font-size', },
45 30 { key = '=', action = wez.action.EmitEvent 'inc-font-size', },
46 - { key = '0', action = wez.action.ResetFontSize, },
31 + { key = '0', action = wez.action.EmitEvent 'reset-font-size', },
33 + -- these actually SCALE the font, not actually change the size...
34 + -- { key = '-', action = wez.action.DecreaseFontSize, },
35 + -- { key = '=', action = wez.action.IncreaseFontSize, },
36 + -- { key = '0', action = wez.action.ResetFontSize, },
38 + { key = 'Enter', action = wez.action.EmitEvent 'change-font-size', },
39 + { key = 'Space', action = wez.action.EmitEvent 'random-codefont', },
48 41 { key = 'UpArrow', action = wez.action.EmitEvent 'like-current-font', },
49 42 { key = 'DownArrow', action = wez.action.EmitEvent 'dislike-current-font', },
76 69 key = '0',
77 70 mods = 'LEADER',
78 - action = wez.action.ActivateKeyTable { name = font_mode, one_shot = false, },
71 + action = wez.action.ActivateKeyTable { name = font_mode, one_shot = true, },
81 74 key = 'w',
119 112 { Foreground = { AnsiColor = 'Purple', }, },
120 113 { Text = 'New workspace:', },
122 - -- FIXME: move to workspace module and use emitevent instead of custom_action
123 115 action = wez.action_callback( function ( window, pane, line )
124 116 if line then
125 117 window:perform_action(
191 183 mods = 'LEADER',
192 184 action = workspace_switcher.switch_workspace(),
187 + key = 'k',
188 + mods = 'LEADER',
189 + action = wez.action.SwitchToWorkspace { name = 'dotfiles', },
190 + },
195 192 key = '/',
196 193 mods = 'LEADER',
206 203 mods = 'LEADER',
207 204 action = wez.action.QuitApplication,
209 - {
210 - key = 'k',
211 - mods = 'LEADER',
212 - action = wez.action.SwitchToWorkspace { name = 'dotfiles', },
213 - },
216 208 -- Navigate Tabs by LEADER+n

wezterm/bugabinga/mouse_binds.lua

Modified
3 3 local wez = require 'wezterm'
5 5 local bindings = {
7 7 event = { Down = { streak = 3, button = 'Left', }, },
8 - -- FIXME: this needs integration in nushel
8 + -- FIXME: this needs integration in nushell
9 9 action = wez.action.SelectTextAtMouseCursor 'SemanticZone',
10 10 mods = 'NONE',

wezterm/bugabinga/status.lua

Modified
35 35 { Attribute = { Intensity = 'Bold', }, },
36 36 { Text = table.concat( fonts, ', ' ), },
37 37 { Text = ' ', },
38 - 'ResetAttributes',
40 39 local pane_domain = pane:get_domain_name()
54 53 { Text = '@', },
55 54 { Attribute = { Intensity = 'Bold', }, },
56 55 { Text = pane_domain, },
57 - 'ResetAttributes',
59 57 table.insert( status, context )
63 61 window:set_right_status(
64 62 wez.format {
65 - { Foreground = { AnsiColor = 'White', }, },
66 63 { Text = table.concat( status, DELIMITER ), },
67 - 'ResetAttributes',
70 66 window:set_left_status(
71 67 wez.format {
72 - { Foreground = { AnsiColor = 'White', }, },
73 68 { Text = '  ', },
74 - 'ResetAttributes',
77 71 end )

wezterm/bugabinga/title.lua

Deleted
deleted file mode 100644
1 -local wez = require 'wezterm'
3 -local icons = {
4 - '',
5 - '',
6 - '',
7 - '',
8 - '',
9 - '',
10 - '',
11 - '',
12 - '',
13 -
14 -}
15 -wez.on('format-window-title', function(tab, pane, tabs, panes, config)
16 - local zoomed = ''
17 - if tab.active_pane.is_zoomed then
18 - zoomed = '[Z] '
19 - end
21 - local index = ''
22 - if #tabs > 1 then
23 - index = string.format('[%d/%d] ', tab.tab_index + 1, #tabs)
24 - end
26 - return zoomed .. index .. tab.active_pane.title
27 -end)

wezterm/bugabinga/window.lua

Modified
4 4 return function ( cfg )
5 5 cfg.window_background_opacity = 1.0
6 6 cfg.window_decorations = 'NONE'
7 7 cfg.enable_wayland = true
8 8 cfg.use_resize_increments = true
9 9 cfg.window_padding = {
10 - left = 0,
11 - right = 0,
10 + left = 2,
11 + right = 2,
12 12 top = 0,
13 13 bottom = 0,

wezterm/bugabinga/workspace_switcher.lua

Added
new file mode 100644
1 +--- stolen and adapted from https://github.com/MLFlexer/smart_workspace_switcher.wezterm/blob/main/plugin/init.lua
3 +local wezterm = require 'wezterm'
4 +local act = wezterm.action
5 +local mux = wezterm.mux
7 +local zoxide_path = 'zoxide'
9 +local is_windows = string.find( wezterm.target_triple, 'windows' ) ~= nil
11 +local function workspace_formatter( label )
12 + return wezterm.format {
13 + { Text = '󱂬 : ' .. label, },
14 + }
15 +end
17 +local run_child_process = function ( cmd )
18 + local process_args = { os.getenv 'SHELL', '-c', cmd, }
19 + if is_windows then
20 + process_args = { 'cmd', '/c', cmd, }
21 + end
22 + local success, stdout, stderr = wezterm.run_child_process( process_args )
24 + if not success then
25 + wezterm.log_error( "Child process '" .. cmd .. "' failed with stderr: '" .. stderr .. "'" )
26 + end
27 + return stdout
28 +end
30 +local function get_workspace_elements( choice_table )
31 + local workspace_ids = {}
32 + for _, workspace in ipairs( mux.get_workspace_names() ) do
33 + table.insert( choice_table, {
34 + id = workspace,
35 + label = workspace_formatter( workspace ),
36 + } )
37 + workspace_ids[workspace] = true
38 + end
39 + return choice_table, workspace_ids
40 +end
42 +local function get_zoxide_elements( choice_table, workspace_ids )
43 + local stdout = run_child_process( zoxide_path .. ' query -l ' )
45 + for _, path in ipairs( wezterm.split_by_newlines( stdout ) ) do
46 + local updated_path = string.gsub( path, wezterm.home_dir, '~' )
47 + if not workspace_ids[updated_path] then
48 + table.insert( choice_table, {
49 + id = path,
50 + label = updated_path,
51 + } )
52 + end
53 + end
54 + return choice_table
55 +end
57 +local function get_choices()
58 + local choices = {}
59 + local workspace_ids = get_workspace_elements( choices )
60 + get_zoxide_elements( choices, workspace_ids )
61 + return choices
62 +end
64 +local function zoxide_chosen( window, pane, path, label_path )
65 + window:perform_action(
66 + act.SwitchToWorkspace {
67 + name = label_path,
68 + spawn = {
69 + label = 'Workspace: ' .. label_path,
70 + cwd = path,
71 + },
72 + } ,
73 + pane
74 + )
75 + -- increment zoxide path score
76 + run_child_process( zoxide_path .. ' add ' .. path )
77 +end
79 +local function workspace_chosen( window, pane, workspace )
80 + window:perform_action(
81 + act.SwitchToWorkspace {
82 + name = workspace,
83 + } ,
84 + pane
85 + )
86 +end
88 +local function workspace_exists( workspace )
89 + for _, workspace_name in ipairs( mux.get_workspace_names() ) do
90 + if workspace == workspace_name then
91 + return true
92 + end
93 + end
94 + return false
95 +end
97 +local function switch_workspace()
98 + return wezterm.action_callback( function ( window, pane )
99 + wezterm.emit( 'smart_workspace_switcher.workspace_switcher.start', window, pane )
100 + local choices = get_choices()
102 + window:perform_action(
103 + act.InputSelector {
104 + action = wezterm.action_callback( function ( inner_window, inner_pane, id, label )
105 + if id and label then
106 + if workspace_exists( id ) then
107 + -- workspace is choosen
108 + workspace_chosen( inner_window, inner_pane, id )
109 + else
110 + -- path is choosen
111 + zoxide_chosen( inner_window, inner_pane, id, label )
112 + end
113 + else
114 + wezterm.emit( 'smart_workspace_switcher.workspace_switcher.canceled', window, pane )
115 + end
116 + end ),
117 + title = 'Choose Workspace',
118 + description = 'Select a workspace and press Enter = accept, Esc = cancel, / = filter',
119 + fuzzy_description = 'Workspace to switch: ',
120 + choices = choices,
121 + fuzzy = true,
122 + },
123 + pane
125 + end )
126 +end
128 +return {
129 + switch_workspace = switch_workspace,

wezterm/wezterm.lua

Modified
2 2 local wez = require 'wezterm'
3 3 local cfg = wez.config_builder()
5 5 require 'bugabinga.theme' ( cfg )
6 +require 'bugabinga.startup' ( cfg )
6 7 require 'bugabinga.options' ( cfg )
7 8 require 'bugabinga.key_binds' ( cfg )
8 9 require 'bugabinga.mouse_binds' ( cfg )
9 10 require 'bugabinga.fonts' ( cfg )
10 11 require 'bugabinga.window' ( cfg )
11 -require 'bugabinga.startup' ( cfg )
12 12 require 'bugabinga.status' ( cfg )
13 13 require 'bugabinga.titles' ( cfg )
14 14 require 'bugabinga.launch' ( cfg )
15 15 require 'bugabinga.neovim_zen_mode' (cfg)
16 -require 'bugabinga.hosts' ( cfg )
17 16 require 'bugabinga.dotfiles_workspace' ( cfg )
17 +require 'bugabinga.hosts' ( cfg )
19 19 -- logs key presses
20 20 -- cfg.debug_key_events = true,