iTerm2 icon indicating copy to clipboard operation
iTerm2 copied to clipboard

Smart Selection "Word bounded by WS" now omits trailing * or @ character

Open alanhoyle opened this issue 4 years ago • 1 comments

This changes the default behavior of Smart Selection so that the "word bounded by Whitespace" regex does not include trailing @ or * characters by default. This improves behavior of the selector for those of us who use ls -F by default.

ls -F displays a character at the end of a filename to indicate special file types or directories. E.g. it adds a "*" to executable files and an "@" at the end of symbolic links. The default regex of \S+ includes those characters which can cause weird side effects with a typical pattern of use like this ls, user selects filename, user pastes into another command line window. The default would include executable_file* or symbolic_link@ which doesn't exist or might refer to multiple files.

The trailing * is especially troublesome in cases where there are multiple files of the same name. For example:

$ ls -F /usr/bin/* |grep ssh
/usr/bin/ssh*
/usr/bin/ssh-add*
/usr/bin/ssh-agent*
/usr/bin/ssh-copy-id*
/usr/bin/ssh-keygen*
/usr/bin/ssh-keyscan*

If someone tries to run /usr/bin/ssh* we'll get en error as the shell will expand to include the other files:

$ /usr/bin/ssh*
ssh: Could not resolve hostname /usr/bin/ssh-add: nodename nor servname provided, or not known

alanhoyle avatar Dec 21 '20 17:12 alanhoyle

I also use ls -F so I can definitely sympathize with this desire, but I don't think enough people use it to justify changing this default.

gnachman avatar Dec 24 '20 06:12 gnachman