repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

wezterm: keybinds to like and dislike current code font.

b8331c2b3eeaa47a610ca7e31df5627087fc1ee5

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (6)

neovim/lazy-lock.json

Modified
51 51 "nvim-neoclip.lua": { "branch": "main", "commit": "32e05f2d23dc5b6a284a688c0535a83d1bfc633f" },
52 52 "nvim-rulebook": { "branch": "main", "commit": "bc5e3874a9870709ec91152f9efce6dad49ca862" },
53 53 "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
54 - "nvim-treesitter": { "branch": "master", "commit": "36b78d112bddd69a05e24679241962e29e494d9e" },
54 + "nvim-treesitter": { "branch": "master", "commit": "707313b80a2f1e65fa06dba2052cc49ce6762a60" },
55 55 "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" },
56 56 "nvim-treesitter-textobjects": { "branch": "master", "commit": "4a2d05ec24eaa6b655c7d19092a3b6c0219d46b9" },
57 57 "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
60 60 "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
61 61 "precognition.nvim": { "branch": "main", "commit": "8a81c310b4e76b4884fc5350a5741cf683c645c7" },
62 62 "range-highlight.nvim": { "branch": "master", "commit": "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9" },
63 - "refjump.nvim": { "branch": "main", "commit": "ae526d94864ddabced9cdb44d2158c9b3d6e0d9c" },
63 + "refjump.nvim": { "branch": "main", "commit": "a78b585cff29505f7558f3a596bca567474cd663" },
64 64 "scratch.nvim": { "branch": "main", "commit": "3e3d2ad0d7f565bc794d9d3ad40e92509802ecad" },
65 65 "specs.nvim": { "branch": "main", "commit": "8a108c8b37dec1b184a1d3d76c6cf867bfbe9636" },
66 66 "spellwarn.nvim": { "branch": "main", "commit": "2f4dbc58bb90bc63b295461216b91ccf4e7f782d" },

wezterm/bugabinga/code_font.lua

Modified
1 1 local wez = require 'wezterm'
3 -return {
4 - random = function ()
5 - local selected = 'JetBrains Mono' -- safe default, because built in to wezterm
6 - local font_names = {}
7 - local weights = {}
8 - local total_weight = 1 -- to account for luas 1 based indexing
9 - local code_fonts = io.open( wez.config_dir .. '/bugabinga/code_fonts.csv', 'r' )
11 - if code_fonts then
12 - for line in code_fonts:lines() do
13 - local weight, font_name = line:match '^%s*(%d*)%s*,%s*(.*)%s*$'
14 - table.insert( font_names, font_name )
15 - table.insert( weights, tonumber( weight ) )
16 - total_weight = total_weight + weight
3 +local adjust_font_randomness_weight = function ( font_family, adjust )
4 + local code_fonts = io.open( wez.config_dir .. '/bugabinga/code_fonts.csv', 'r+' )
5 + if code_fonts then
6 + local new_lines = {}
7 + for line in code_fonts:lines() do
8 + local weight, font_name = line:match '^%s*(%d+)%s*,%s*(.-)%s*$'
9 + if not weight or not font_name then
10 + wez.log_error 'Could not parse code_fonts.csv. Borked?'
11 + return
18 - code_fonts:close()
13 + weight = tonumber( weight )
14 + if font_name == font_family then
15 + weight = math.max( 0, adjust( weight ) )
16 + end
17 + table.insert( new_lines, weight .. ', ' .. font_name )
18 + end
19 + code_fonts:seek( 'set', 0 )
20 + for _, new_line in ipairs( new_lines ) do
21 + code_fonts:write( new_line, '\n' )
22 + end
23 + code_fonts:close()
24 + else
25 + wez.log_error 'Unable to read and write code_fonts.csv!'
26 + end
27 +end
20 - local random_weight = math.random( total_weight )
21 - local cursor = 0
22 - for idx, weight in ipairs( weights ) do
23 - cursor = cursor + weight
24 - if cursor >= random_weight then
25 - selected = font_names[idx]
26 - break
27 - end
29 +-- like the current font.
30 +-- liked fonts have higher probablity of being picked on wezterm boot.
31 +-- increase the weight of the font in code_fonts.csv.
32 +-- not to be confused with a font weigth (aka bold).
33 +-- here weight means the likelyhood of being "randomly" picked.
34 +local like_current_font = function ( window )
35 + local font = window:effective_config().font.font
36 + -- not sure why font is a list
37 + local family = font[1].family
38 + adjust_font_randomness_weight( family, function ( weight )
39 + local new_weight = weight + 1
40 + -- TODO: remove notification once weight is displayed in status
41 + window:toast_notification( 'code_fonts', 'Font ' .. family .. '(' .. new_weight .. ') liked! ', nil, 500 )
42 + return new_weight
43 + end )
44 +end
46 +local dislike_current_font = function ( window )
47 + local font = window:effective_config().font.font
48 + -- not sure why font is a list
49 + local family = font[1].family
50 + adjust_font_randomness_weight( family, function ( weight )
51 + local new_weight = weight - 1
52 + window:toast_notification( 'code_fonts', 'Font ' .. family .. '(' .. new_weight .. ') NOT liked! ', nil, 500 )
53 + return new_weight
54 + end )
55 +end
57 +local ban_current_font = function ( window )
58 + local font = window:effective_config().font.font
59 + -- not sure why font is a list
60 + local family = font[1].family
61 + adjust_font_randomness_weight( family, function ()
62 + window:toast_notification( 'code_fonts', 'Font ' .. family .. ' BANNED!', nil, 500 )
63 + return 0
64 + end )
65 +end
67 +-- register those events with wezterm, so that key binds can trigger them
68 +wez.on( 'like-current-font', like_current_font )
69 +wez.on( 'dislike-current-font', dislike_current_font )
70 +wez.on( 'ban-current-font', ban_current_font )
72 +local random = function ()
73 + local selected = 'JetBrains Mono' -- safe default, because built in to wezterm
74 + local font_names = {}
75 + local weights = {}
76 + local total_weight = 1 -- to account for luas 1 based indexing
77 + local code_fonts = io.open( wez.config_dir .. '/bugabinga/code_fonts.csv', 'r' )
79 + if code_fonts then
80 + for line in code_fonts:lines() do
81 + local weight, font_name = line:match '^%s*(%d+)%s*,%s*(.-)%s*$'
82 + if not weight or not font_name then
83 + wez.log_error 'Could not parse code_fonts.csv. Borked?'
84 + break
85 + end
86 + weight = tonumber( weight )
87 + table.insert( font_names, font_name )
88 + table.insert( weights, weight )
89 + total_weight = total_weight + weight
90 + end
91 + code_fonts:close()
93 + local random_weight = math.random( total_weight )
94 + local cursor = 0
95 + for idx, weight in ipairs( weights ) do
96 + cursor = cursor + weight
97 + if cursor >= random_weight then
98 + selected = font_names[idx]
99 + break
102 + end
31 - return wez.font( selected )
32 - end,
104 + return wez.font( selected )
105 +end
107 +return {
108 + like_current_font = like_current_font,
109 + dislike_current_font = dislike_current_font,
110 + ban_current_font = ban_current_font,
111 + random = random,

wezterm/bugabinga/code_fonts.csv

Modified
1 - 1, Anonymous Pro
2 - 1, Anonymous Pro Minus
3 - 1, Aurulent Sans Mono
4 - 1, AverageMono
5 - 1, BPmono
6 - 1, BigBlue TerminalPlus
7 - 1, Bitstream Vera Sans Mono
8 - 1, Bront
9 - 1, CMU Typewriter Text
10 - 1, CPMono_v07
11 - 1, CamingoCode
12 - 1, Cascadia Code
13 - 1, Code New Roman
14 - 1, CodingFontTobi
15 - 1, Consola Mono
16 - 1, Courier Prime Code
17 - 1, Cousine
18 - 1, Crisp
19 - 1, Cutive Mono
20 - 1, D2Coding
21 - 1, DejaVu Sans Mono
22 - 1, Dina ttf 10px
23 - 1, Droid Sans Mono
24 - 1, Edlo
25 - 1, Envy Code R
26 - 1, Fantasque Sans Mono
27 - 1, Fira Code
28 - 1, Fira Mono
29 - 1, Fixedsys Excelsior 3.01
30 - 1, FreeMono
31 - 1, Geist Mono
32 - 1, Generic Mono II
33 - 1, GohuFont
34 - 1, Hack
35 - 1, Hasklig
36 - 10, Hermit
37 - 10, IBM Plex Mono
38 - 1, Inconsolata
39 - 1, Inconsolata LGC
40 - 1, Inconsolata-dz
41 - 1, Inconsolata-g
42 - 1, Intel One Mono
43 - 1, Iosevka
44 - 1, Iosevka Slab
45 - 1, JetBrains Mono
46 - 1, JetBrains Mono NL
47 - 1, Kawkab Mono
48 - 1, Latin Modern Mono Light
49 - 10, Lekton
50 - 1, Liberation Mono
51 - 1, Lilex
52 - 1, Linux Libertine Mono
53 - 1, Luculent
54 - 1, Luxi Mono
55 - 1, M+ 1m
56 - 1, M+ 1mn
57 - 1, M+ 2m
58 - 1, Martian Mono
59 - 1, Mensch
60 - 0, Meslo LG M DZ
61 - 1, Metrickal
62 - 1, Monaspace Argon Var
63 - 1, Monaspace Krypton Var
64 - 1, Monaspace Neon Var
65 - 1, Monaspace Radon Var
66 - 1, Monaspace Xenon Var
67 - 1, MonoSpatial
68 - 1, Monoid
69 - 1, Monospace
70 - 1, MonteCarlo Fixed 12
71 - 1, NanumGothic_Coding
72 - 1, NotCourierSans
73 - 1, Office Code Pro
74 - 1, Office Code Pro D
75 - 1, Oxygen Mono
76 - 1, PT Mono
77 - 1, Panic Sans
78 - 0, PixelCarnageMonoTT
79 - 1, Pointfree
80 - 1, ProFontWindows
81 - 1, ProggyCleanTT
82 - 1, ProggyCleanTTSZ
83 - 1, ProggySmallTT
84 - 1, ProggySquareTT
85 - 1, ProggySquareTTSZ
86 - 1, ProggyTinyTT
87 - 1, ProggyTinyTTSZ
88 - 1, Rec Mono Casual
89 - 1, Rec Mono Linear
90 - 1, Roboto Mono
91 - 1, SV Basic Manual
92 - 1, Share Tech Mono
93 - 1, Share-TechMonoTrue
94 - 1, SmallTypeWriting
95 - 1, Source Code Pro
96 - 1, Sudo
97 - 1, Symbols Nerd Font
98 - 1, Symbols Nerd Font Mono
99 - 1, TeX Gyre Cursor
100 - 1, Terminus
101 - 1, Ubuntu Mono
102 - 1, Verily Serif Mono
103 - 1, Victor Mono
104 - 1, Whois
105 - 1, agave
106 - 1, iA Writer Mono V
107 - 1, monoOne
108 - 1, monofur
109 - 1, mononoki
110 - 20, saxMono
1 +1, Anonymous Pro
2 +1, Anonymous Pro Minus
3 +1, Aurulent Sans Mono
4 +1, AverageMono
5 +1, BPmono
6 +1, BigBlue TerminalPlus
7 +1, Bitstream Vera Sans Mono
8 +1, Bront
9 +1, CMU Typewriter Text
10 +1, CPMono_v07
11 +1, CamingoCode
12 +1, Cascadia Code
13 +1, Code New Roman
14 +1, CodingFontTobi
15 +1, Consola Mono
16 +1, Courier Prime Code
17 +1, Cousine
18 +1, Crisp
19 +1, Cutive Mono
20 +1, D2Coding
21 +1, DejaVu Sans Mono
22 +1, Dina ttf 10px
23 +1, Droid Sans Mono
24 +1, Edlo
25 +1, Envy Code R
26 +1, Fantasque Sans Mono
27 +1, Fira Code
28 +1, Fira Mono
29 +1, Fixedsys Excelsior 3.01
30 +1, FreeMono
31 +1, Geist Mono
32 +20, Generic Mono II
33 +1, GohuFont
34 +1, Hack
35 +1, Hasklig
36 +11, Hermit
37 +11, IBM Plex Mono
38 +1, Inconsolata
39 +1, Inconsolata LGC
40 +1, Inconsolata-dz
41 +1, Inconsolata-g
42 +1, Intel One Mono
43 +1, Iosevka
44 +1, Iosevka Slab
45 +0, JetBrains Mono
46 +0, JetBrains Mono NL
47 +1, Kawkab Mono
48 +1, Latin Modern Mono Light
49 +11, Lekton
50 +1, Liberation Mono
51 +1, Lilex
52 +1, Linux Libertine Mono
53 +1, Luculent
54 +1, Luxi Mono
55 +1, M+ 1m
56 +1, M+ 1mn
57 +1, M+ 2m
58 +1, Martian Mono
59 +1, Mensch
60 +0, Meslo LG M DZ
61 +1, Metrickal
62 +1, Monaspace Argon Var
63 +1, Monaspace Krypton Var
64 +1, Monaspace Neon Var
65 +1, Monaspace Radon Var
66 +1, Monaspace Xenon Var
67 +1, MonoSpatial
68 +1, Monoid
69 +1, Monospace
70 +1, MonteCarlo Fixed 12
71 +1, NanumGothic_Coding
72 +1, NotCourierSans
73 +1, Office Code Pro
74 +1, Office Code Pro D
75 +6, Oxygen Mono
76 +1, PT Mono
77 +1, Panic Sans
78 +0, PixelCarnageMonoTT
79 +1, Pointfree
80 +1, ProFontWindows
81 +1, ProggyCleanTT
82 +1, ProggyCleanTTSZ
83 +1, ProggySmallTT
84 +1, ProggySquareTT
85 +1, ProggySquareTTSZ
86 +1, ProggyTinyTT
87 +1, ProggyTinyTTSZ
88 +1, Rec Mono Casual
89 +1, Rec Mono Linear
90 +1, Roboto Mono
91 +1, SV Basic Manual
92 +1, Share Tech Mono
93 +1, Share-TechMonoTrue
94 +1, SmallTypeWriting
95 +1, Source Code Pro
96 +1, Sudo
97 +1, Symbols Nerd Font
98 +1, Symbols Nerd Font Mono
99 +1, TeX Gyre Cursor
100 +1, Terminus
101 +1, Ubuntu Mono
102 +1, Verily Serif Mono
103 +1, Victor Mono
104 +1, Whois
105 +1, agave
106 +1, iA Writer Mono V
107 +1, monoOne
108 +1, monofur
109 +1, mononoki
110 +0, saxMono

wezterm/bugabinga/fonts.lua

Modified
1 1 local wez = require 'wezterm'
3 3 return function ( cfg )
4 - local font_size = 16.0
4 + local font_size = 11.0
5 5 local font = wez.font 'Cousine'
6 6 cfg.font = font
7 7 cfg.font_size = font_size

wezterm/bugabinga/key_binds.lua

Modified
10 10 if wez.target_triple:find 'windows' then
11 11 leader = { key = 'raw:255', }
13 -local font_size_mode = ' Change Font Size (=-+)'
13 +local font_mode = ' Font mode (-=🠙🠛␡)'
14 14 local pane_mode = ' Pane (hjklqr)'
15 15 local resize_pane_mode = 'ﭕ Resize Pane (hjkl)'
17 +wez.on("inc-font-size", function(window)
18 + local size = window:effective_config().font_size + 1
19 + local overrides = window:get_config_overrides() or {}
20 + overrides.font_size = size
21 + window:set_config_overrides(overrides)
22 +end)
24 +wez.on("dec-font-size", function(window)
25 + local size = window:effective_config().font_size - 1
26 + local overrides = window:get_config_overrides() or {}
27 + overrides.font_size = size
28 + window:set_config_overrides(overrides)
29 +end)
17 31 local key_tables = {
18 32 [resize_pane_mode] = {
19 33 { key = 'h', action = wez.action.AdjustPaneSize { 'Left', 1, }, },
24 38 -- Cancel the mode
25 39 { key = 'Escape', action = 'PopKeyTable', },
27 - [font_size_mode] = {
28 - { key = '-', action = wez.action.DecreaseFontSize, },
29 - { key = '=', action = wez.action.IncreaseFontSize, },
41 + [font_mode] = {
42 + { key = '-', action = wez.action.EmitEvent 'dec-font-size', },
43 + { key = '=', action = wez.action.EmitEvent 'inc-font-size', },
30 44 { key = '0', action = wez.action.ResetFontSize, },
46 + { key = 'UpArrow', action = wez.action.EmitEvent 'like-current-font' },
47 + { key = 'DownArrow', action = wez.action.EmitEvent 'dislike-current-font' },
48 + { key = 'Delete', action = wez.action.EmitEvent 'ban-current-font' },
32 50 { key = 'Escape', action = 'PopKeyTable', },
34 52 [pane_mode] = {
54 72 key = '0',
55 73 mods = 'LEADER',
56 - action = wez.action.ActivateKeyTable { name = font_size_mode, one_shot = false, },
74 + action = wez.action.ActivateKeyTable { name = font_mode, one_shot = false, },
59 77 key = 'w',
97 115 { Foreground = { AnsiColor = 'Purple', }, },
98 116 { Text = 'New workspace:', },
118 + -- FIXME: move to workspace module and use emitevent instead of custom_action
100 119 action = wez.action_callback( function ( window, pane, line )
101 120 if line then
102 121 window:perform_action(

wezterm/bugabinga/status.lua

Modified
22 22 local zoomed_state = zoomed( pane )
23 23 local leader = nil
24 24 if window:leader_is_active() then
25 - leader = 'LEADER'
25 + leader = '󱁐 '
27 27 local fonts = {}
28 28 local config = window:effective_config()
39 39 local pane_domain = pane:get_domain_name()
41 - local status = { '', }
41 + local status = { ' ', }
42 42 if leader then
43 43 table.insert( status, leader )