joshmedeski / t-smart-tmux-session-manager

t - the smart tmux session manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: allow paths zoxide doesn't know

TxHawks opened this issue · comments

First, I love the workflow that inspired this plugin. It's so simple while remaining super powerful.

I sometimes want to start a session for a dir that I've just now created or that zoxide doesn't yet know for some reason, and it'd be a nice if there was an option to treat the string in the input as a path to open a session for if there are no results from the fzf filter.

So, for example, if I want to create a session for a bar project, which I haven't visited in months and is no longer in the zoxide query output. I type /Users/foo/repos/bar/ and there are no results, it'd be nice if the plugin checked if the path exists and is a directory, and then open a session for it.

The --print-query option of fzf can be used for that, and if you like the idea, I'd be happy to implement it and send a PR

Actually, I went ahead and implemented this general idea a bit differently, in a way I think is more useful. I added a path binding that uses fd to list subdirectories of the home dir, and isn't included in the the results of default all prompt. So basically, in the odd case you want a path that isn't in zoxide for whatever reason, you can opt-in to querying your file system, but it doesn't pollute the default results.

You can see the changes I made here, and if you think this is a good idea, I'd be happy to open a pull request.

One downside to this change though, is that it adds a dependency on fd. I could check if fd exists and fall back to using find otherwise, but find is a lot slower and it'll make the code a bit more complex.

Hey @TxHawks I love this idea!

Please submit the PR, and I do think falling back to find if fd isn't found is a good idea. I'll play around with your PR and let you know if I have any feedback on the functionality.

Okay, I've added a a fallback and opening a pull request

Hey, I went ahead and create a simpler solution, check out #14

Hey, I decided to add the fd fallback in with #15

I'm realizing now that ctrl+p is a helpful fallback sometimes, the extra time it takes to load and the amount of results returned isn't as big of a deal as it seemed at first.

This works great now, and adding the path to zoxide is of course the right thing to do, just slipped my mind in the initial implementation.

The only thing is that because of the way fd works, paths now doesn't include the home dir itself (unlike the find fallback, which does). Strangely, fd actually doesn't have a way to include the current working directory in its results, so we'd need to echo it before the fd results (see echo $HOME here).

Want me to send a pull request?

Thanks for clarifying, I added the echo ;)

Perfect. Thanks!

Hey everyone, could the keybinding be changed to something other than Ctrl-p?

It's common to use Ctrl-p and Ctrl-n for navigating to prev/next and is also something fzf has built in so this keybinding broke that 😅

What do you have in mind? I'd like to keep ctrl-p as well.

Maybe ctrl-d for directory?

Ctrl-d sounds like a good choice to me 👍