tmux filename matching: don't match prefix spaces
dblume

dblume commited on 2025-11-28 12:36:59
Showing 1 changed files, with 1 additions and 1 deletions.


Turns out I didn't need to match spaces or specify '/<' word
start boundaries. This slightly shorter regex passes all my
tests.
... ...
@@ -44,7 +44,7 @@ bind -n M-l select-pane -R
44 44
 # 3. Navigate selections with n/N.
45 45
 # 4. Once found, o to open the file in $EDITOR.
46 46
 bind-key f copy-mode \; send-keys -X search-backward \
47
-  '(^|[[:space:]])(("([[:alnum:] _\.#$%&+=@-]+|~)?(/[[:alnum:] _\.#$%&+=@-]+)*"|([[:alnum:]_\.#$%&+=@-]+|~)?(/[[:alnum:]_\.#$%&+=@-]+)+|[[:alnum:]_\.#$%&+=@-]*[[:alpha:]][[:alnum:]_\.#$%&+=@-]*)(:[0-9]{1,10})|(([[:alnum:]_\.#$%&+=@-]*[[:alpha:]][[:alnum:]_\.#$%&+=@-]*|~|\.|\.\.)(/[[:alnum:]_\.#$%&+=@-]+)?\.[[:alnum:]]{1,4}|([[:alnum:]_\.#$%&+=@-]+|~)?(/[[:alnum:]_\.#$%&+=@-]+){2,})(:[0-9]{1,10})?)(:[0-9]{1,10})?(\>|$)'
47
+  '(("([[:alnum:] _\.#$%&+=@-]+|~)?(/[[:alnum:] _\.#$%&+=@-]+)*"|(([[:alnum:]_\.#$%&+=@-]+|~)?(/[[:alnum:]_\.#$%&+=@-]+)+|[[:alnum:]_\.#$%&+=@-]*[[:alpha:]][[:alnum:]_\.#$%&+=@-]*))(:[0-9]{1,10})|(([[:alnum:]_\.#$%&+=@-]*[[:alpha:]][[:alnum:]_\.#$%&+=@-]*|~|\.|\.\.)(/[[:alnum:]_\.#$%&+=@-]+)?\.[[:alnum:]]{1,4}|([[:alnum:]_\.#$%&+=@-]+|~)?(/[[:alnum:]_\.#$%&+=@-]+){2,})(:[0-9]{1,10})?)(:[0-9]{1,10})?(\>|$)'
48 48
 
49 49
 # save the buffer, then open an editor in the current pane
50 50
 bind-key -T copy-mode-vi o send-keys -X copy-pipe-and-cancel \
51 51