omerxx / tmux-sessionx

A Tmux session manager, with preview, fuzzy finding, and MORE
GNU General Public License v3.0
554 stars 51 forks source link

Not being able to set sessionx-custom-paths. #93

Closed sarojregmi200 closed 1 month ago

sarojregmi200 commented 1 month ago

Thanks you for the plugin, @omerxx.

While setting up tmux-sessionx I wanted to set some options in the session list that are already present without creating any session. So, that it's easy to just navigate to those locations while creating a new session.

The config option for what I want is present here: https://github.com/omerxx/tmux-sessionx/blob/ac9b0ec219c2e36ce6beb3f900ef852ba8888095/README.md?plain=1#L41C1-L44C74

My implementation:

set -g @sessionx-custom-paths 'mylocation/Documents/projects/' # to set persisting sessions

But I donot see the projects path in my list of sessions. Am I missing something?

sarojregmi200 commented 1 month ago

After looking at the source code and tinkering with it a little bit. I found out where my configuration was wrong.

set -g @sessionx-custom-paths 'mylocation/Documents/projects/' # to set persisting sessions

Here I specified documents/projects/ with a trailing slash. And according to the pattern matching in the below code: https://github.com/omerxx/tmux-sessionx/blob/ac9b0ec219c2e36ce6beb3f900ef852ba8888095/scripts/sessionx.sh#L85C4-L87C6

if [[ $sessions == *"${i##*/}"* ]]; then
continue             

It gets converted to:

if [[ $sessions == *""* ]]; then
continue             

which skips printing the default sessions that are specified with a trailing /.

Solutions:

I would love to know your thinking of this.

omerxx commented 1 month ago

Hey @sarojregmi200 and thank you! Yes, you solution seems at a first glance like a more elegant option, I'm just worried about different shells support for basename. I know bash and fish support it. Do you think it would make any other difference other than solving the trailing slash issue?

Also, I wonder about the backward compatibility of existing users.

If you think both are ok, would you like to open a PR with changes and test it?

Thanks!

sarojregmi200 commented 1 month ago

I have done some research in bash and it works there but have not tested in other shells. I will submit a pr once I confirm backwards compatibility and shells compatibility.