sainnhe / tmux-fzf

Use fzf to manage your tmux work environment!
MIT License
991 stars 53 forks source link

Session names that contain spaces are unusable #60

Closed Avishayy closed 1 year ago

Avishayy commented 1 year ago

Specifically, the grep pattern in session.sh

target=$(echo "$target_origin" | grep -o '^[[:alpha:][:digit:]/_-]*:' | sed 's/.$//g')

won't match on sessions such as My Session, as a space (or any whitespace character for that matter) won't be matched under the above character set.

Even if the above was fixed naively by changing to pattern

'^[[:alpha:][:digit:]/_ -]*:'

(there's now a space after the underscore)

The attach (or any action for that matter) will still fail because of xargs:

echo "$target" | xargs tmux switch-client -t

xargs delimits the parameters by space so switch-client sees two arguments instead of one (the session name with the space). I assume this is written this way to support multi selection, but it doesn't seem to work regardless to me.

Locally I've patched the grep pattern to include space and xargs was removed from the attach command and is now used as

tmux switch-client -t "$target"

and it works.