Created
March 7, 2026 05:55
-
-
Save nazt/2144cb0147b50cc00eb2f56df0628dda to your computer and use it in GitHub Desktop.
WezTerm config — CMD+Click remote files via sshfs, relative path resolution, smart image paste
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local wezterm = require 'wezterm' | |
| local act = wezterm.action | |
| local config = wezterm.config_builder() | |
| -- Font: Nerd Font for starship icons | |
| config.font_size = 13.0 | |
| -- Catppuccin Mocha (matches starship palette) | |
| config.color_scheme = 'Catppuccin Mocha' | |
| config.colors = { | |
| background = '#0a0e14', | |
| } | |
| config.hyperlink_rules = wezterm.default_hyperlink_rules() | |
| -- Remote white.local paths → local sshfs mounts | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[/home/nat/([^ \t:),'"'`]+)]], | |
| format = 'file:///opt/white/$1', | |
| }) | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[/home/openclaw/([^ \t:),'"'`]+)]], | |
| format = 'file:///opt/openclaw/$1', | |
| }) | |
| -- Local absolute paths | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[(/Users/[^ \t:),'"'`]+)]], | |
| format = 'file://$1', | |
| }) | |
| -- ~/path style | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[~/([^ \t:),'"'`]+)]], | |
| format = 'file:///Users/nat/$1', | |
| }) | |
| -- Relative paths — ./path and ψ/path (resolved via OSC 7 cwd on click) | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[(\./[^ \t:),'"'`]+)]], | |
| format = 'rel:$1', | |
| }) | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[(?<!/)(ψ/[^ \t:),'"'`]+)]], | |
| format = 'psi:$1', | |
| }) | |
| -- Rewrite remote cwd to local sshfs path | |
| local function resolve_cwd(pane) | |
| local cwd = pane:get_current_working_dir() | |
| if not cwd then return nil end | |
| local p = cwd.file_path or '' | |
| p = p:gsub('^/home/openclaw/', '/opt/openclaw/') | |
| p = p:gsub('^/home/nat/', '/opt/white/') | |
| return p | |
| end | |
| -- Intercept link clicks to resolve relative paths using OSC 7 cwd | |
| wezterm.on('open-uri', function(window, pane, uri) | |
| -- psi: and rel: schemes — resolve relative to cwd | |
| local rel = uri:match('^psi:(.+)$') or uri:match('^rel:(.+)$') | |
| if rel then | |
| rel = rel:gsub('^%./', '') -- strip leading ./ | |
| local cwd_path = resolve_cwd(pane) | |
| if cwd_path then | |
| wezterm.open_with(cwd_path .. '/' .. rel) | |
| end | |
| return false | |
| end | |
| -- file:// URIs — force open with TextEdit if macOS doesn't know the type | |
| local path = uri:match('^file://(.+)$') | |
| if path then | |
| local success = wezterm.run_child_process({ '/usr/bin/open', path }) | |
| if not success then | |
| wezterm.run_child_process({ '/usr/bin/open', '-a', 'TextEdit', path }) | |
| end | |
| return false | |
| end | |
| end) | |
| -- Smart CMD+V: image in clipboard → save to sshfs + paste path, else normal paste | |
| config.keys = { | |
| { | |
| key = 'v', | |
| mods = 'CMD', | |
| action = wezterm.action_callback(function(window, pane) | |
| local success, stdout = wezterm.run_child_process({ | |
| '/bin/bash', '-c', | |
| 'f="/opt/white/Code/tmp/clipboard/$(date +%Y%m%d-%H%M%S).png"; ' | |
| .. 'mkdir -p /opt/white/Code/tmp/clipboard 2>/dev/null; ' | |
| .. '/opt/homebrew/bin/pngpaste "$f" 2>/dev/null && ' | |
| .. 'echo "/home/nat/Code/tmp/clipboard/$(basename $f)"' | |
| }) | |
| if success and stdout and stdout:match('%.png') then | |
| pane:send_text(stdout:gsub('%s+$', '')) | |
| else | |
| window:perform_action(act.PasteFrom 'Clipboard', pane) | |
| end | |
| end), | |
| }, | |
| } | |
| -- iTerm2 style: CMD+Click opens links, plain click selects text | |
| config.mouse_bindings = { | |
| { | |
| event = { Up = { streak = 1, button = 'Left' } }, | |
| mods = 'NONE', | |
| action = act.CompleteSelection 'ClipboardAndPrimarySelection', | |
| }, | |
| { | |
| event = { Up = { streak = 1, button = 'Left' } }, | |
| mods = 'CMD', | |
| action = act.OpenLinkAtMouseCursor, | |
| }, | |
| { | |
| event = { Down = { streak = 1, button = 'Left' } }, | |
| mods = 'CMD', | |
| action = act.Nop, | |
| }, | |
| } | |
| return config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment