Better tmux filepath selection.
dblume

dblume commited on 2025-11-15 20:38:34
Showing 1 changed files, with 6 additions and 4 deletions.


See links in the code. There's a useful GitHub Gist.
... ...
@@ -37,12 +37,14 @@ bind -n M-j select-pane -D
37 37
 bind -n M-k select-pane -U
38 38
 bind -n M-l select-pane -R
39 39
 
40
-# These next two bind-key f and o are from: https://jyn.dev/how-i-use-my-terminal/
41
-# 1. Do a `rg` search.
40
+# These next two bind-keys, f and o, are from: https://jyn.dev/how-i-use-my-terminal/
41
+# Validation of the regex: https://gist.github.com/dblume/51d36f5656ecbb03012c604e4156ecd6
42
+# 1. Do a `rg` search or get a backtrace or compile error.
42 43
 # 2. Prefix + f to enter copy mode and search backward for a file path regex.
43
-# 3. Once found, Prefix + o to open the file in $EDITOR.
44
+# 3. Navigate selections with n/N.
45
+# 4. Once found, o to open the file in $EDITOR.
44 46
 bind-key f copy-mode \; send-keys -X search-backward \
45
-  '(^|\<|[[:space:]/])(("(~/|/)?[[:alnum:] _\.#$%&+=@-]+(/[[:alnum:] _\.#$%&+=@-]+)*"|(~/|/)?[[:alnum:]_\.#$%&+=@-]+(/[[:alnum:]_\.#$%&+=@-]+)*[[:alnum:]_\.#$%&+=@-]+):[0-9]{1,10}(:[0-9]{1,10})?)|~?/[[:alnum:]_\.#$%&+=@-]+(/[[:alnum:]_\.#$%&+=@-]+)+|[[:alnum:]_\.#$%&+=@-]+(/[[:alnum:]_\.#$%&+=@-]+){2,}'
47
+  '(^|\<|[[:space:]/])(("([[:alnum:] _\.#$%&+=@-]+|~)?(/[[:alnum:] _\.#$%&+=@-]+)*"|([[:alnum:]_\.#$%&+=@-]+|~)?(/[[:alnum:]_\.#$%&+=@-]+)+|[[:alnum:]_\.#$%&+=@-]+[[:alpha:]_\.\#$%&+=@-])(:[0-9]{1,10})|([[:alnum:]_\.#$%&+=@-]+|~)?(/[[:alnum:]_\.#$%&+=@-]+){2,}(:[0-9]{1,10})?)(:[0-9]{1,10})?'
46 48
 
47 49
 # save the buffer, then open an editor in the current pane
48 50
 bind-key -T copy-mode-vi o send-keys -X copy-pipe-and-cancel \
49 51