Created
March 6, 2026 16:19
-
-
Save nazt/90f489061f9f473ca513dbca575e06d8 to your computer and use it in GitHub Desktop.
WezTerm config: CMD+Click remote files via sshfs + OSC 7 relative path resolution
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() | |
| config.hyperlink_rules = wezterm.default_hyperlink_rules() | |
| -- Remote white.local paths → local sshfs mount | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[/home/nat/Code/([^ \t:),'"']+)]], | |
| format = 'file:///opt/white/$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 — tag with psi: scheme, resolved in open-uri handler | |
| table.insert(config.hyperlink_rules, { | |
| regex = [[(ψ/[^ \t:),'"']+)]], | |
| format = 'psi:$1', | |
| }) | |
| -- Intercept link clicks to resolve psi: relative paths using OSC 7 cwd | |
| wezterm.on('open-uri', function(window, pane, uri) | |
| local rel = uri:match('^psi:(.+)$') | |
| if rel then | |
| local cwd = pane:get_current_working_dir() | |
| if cwd then | |
| local cwd_path = cwd.file_path or '' | |
| -- Rewrite remote /home/nat/Code/ → local sshfs /opt/white/ | |
| cwd_path = cwd_path:gsub('^/home/nat/Code/', '/opt/white/') | |
| local full = cwd_path .. '/' .. rel | |
| wezterm.open_with(full) | |
| end | |
| return false | |
| end | |
| -- All other URIs: default behavior | |
| 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