You may have seen the “fuzzy” Bash completion I linked to in my up
post yesterday. I applied the same technique to my [tm]
utility for completing tmux session and window names.
I find this handy because if I type part of a name thinking I’m jumping to a session, but that session has ended, I end up creating a new session with a partial name. With completion, I can type my partial name and hit tab to be sure there will be a match before running.
If you have no arguments and hit tab, it will list all sessions. Typing any part of a session name will begin matching, e.g. j⇥
will expand to a session named “jekyll,” as will kl⇥
. Any part of the name is valid for matching, and it’s case insensitive.
If you have a session in the arguments already, it will begin completing window names for that session, or listing all windows if you hit tab after a space following the session name. Window names are entirely optional in tm
.
Yes, I cheated a little and defaulted to Ruby for some of the string handling, but I decided a while ago that there’s really no crime in that.
If you’re still reading and are a tmux user, I’ll assume you know what to do with this script. That’s fair, right?