-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show and switch to a window instead of a session #12
Conversation
Thanks for creating I created a PR since others might do the same. Of course, feel free to ignore this change if you don't like it. If you wish, I could also make it configurable, or fix the 2 downsides - though that might lead to a slightly more complicated solution. |
Additional thing: I use the word This is counter-intuitive, for me the only window with special status is the one that I am seeing right now. To fix many windows showing up as active, I included a second check ( |
514e5e6
to
505f8ac
Compare
Thanks for submitting this. It does look like something some people would find useful, so I'm happy to include it. However, in the spirit of keeping the current behaviour as it is for anyone using it, we would need to:
Let me know if you can address the 2 points above. Thanks. |
Done in 1c235b9, named
Fixed in 09ff236. I am now using the delimiter |
Note that window-switching functionality only works when the script being called by tmux. Switching to a specific window (in general, I believe) cannot be done via calling a script via a shell, since you first have to switch to the session and then, when you are in the new session, switch to the correct window. When doing this via a bash script, it will not work, since you are not actually "in" the new session whilst halfway through the script. I hope this make sense 😅. This led me to forgo adding the |
I just noticed that this PR does not retain all functionality of the current program (calling the script from command-line does not work as expected) and I don't have the time to immediately fix this. I will update this later, I'll think about how to do it properly first. |
No worries. Also, please note that there's a big refactor coming up as part of #9 so you might want to keep that in mind to avoid conflicts |
Sounds good, I'll look out for that. Thanks for the heads-up.
|
178ead1
to
805e747
Compare
I rebased from master after the #9 merge and updated this PR. It is ready to go, the new |
The default output is still conf-dot: 2 window(s) ~/.tmux/plugins/tmux-session-wizard ~/email ~/Projects ~/Documents/thesis But with the option "@session-wizard-windows on", the output becomes conf-dot: zsh(1) conf-dot: tmux(2) ~/.tmux/plugins/tmux-session-wizard ~/email ~/Projects `tmux select-window` allows a window to be specified with either an index or a name, and we take the index, which is selected by awk -F"[()]" '{print $(NF-1)}'
805e747
to
b060c79
Compare
@RensOliemans Are you sure that mixed windows with sessions is a good idea? The windows switcher is already implemented in Tmux ( If you want to have windows switcher with similar interface to session-wizard, I would create separate command with only windows names, but personally I would give chance built-in feature because switching to another window is only two key strokes and you have also preview. Let me know what do you think about it. |
@RensOliemans Are you sure that mixed windows with sessions is a good idea?
No! I just like it for myself and my specific workflow :) My workflow is approximately this:
I group my sessions per topic, and windows per task (so for example a "thesis" session, with the windows "latex", "program" and "git"). I often think "alright I need to commit this thesis-related thing", and use your session-switcher with something like `thes git` to find the appropriate window.
I built this because I found myself using your session switcher and nearly always switching to the appropriate window immediately after. `<prefix>w` is great (and the preview is cool), but it's too slow and inflexible for me. Slow since it uses 2 more keystrokes than your program (`/` and `Enter` to start and stop searching), and inflexible because it doesn't have fuzzy search (I frequently distinguish between a "thesis/git" window and a "work/git" one).
The windows switcher is already implemented in Tmux (`<prefix>w`) so I would avoid extending session list with additional data, which will life of a fuzzy finder make harder.
That's OK! I made this PR because I thought it might help you or others, but if it's too specific to my workflow, feel free to reject it - it's your project 👍👍
If you want to have windows switcher with similar interface to session-wizard, I would create separate command with only windows names, but personally I would give chance built-in feature because switching to another window is only two key strokes and you have also preview.
I kept the session names in there because that allows me to distinguish between windows with a prompt like `thes git`. I can also hide it if you want. I recently discovered fzfs beautiful `--with-nth`, which would easily allow this and still enable precise matching.
Let me know what do you think about it.
Do whatever you think is best. I figured that our workflows are probably different (I have only used the `zoxide` path feature once), mine is indeed much more like a `<prefix>w` with fuzzy search.
|
I'm not maintainer, @27medkamal is. I was just curious about your workflow and maybe plan to change a little your implementation.
I didn't concern about using search function, just
Having session name in search is good, but still I think this feature should be separate from main session switcher/creator, because what you want is just windows switcher with fuzzy finder. Let wait for @27medkamal. |
I'm not maintainer, @27medkamal is. I was just curious about your workflow and maybe plan to change a little your implementation.
Ah my bad, I wasn't paying attention.
Having session name in search is good, but still I think this feature should be separate from main session switcher/creator, because what you want is just windows switcher with fuzzy finder. Let wait for @27medkamal.
Yep that's right, I just want a window switcher with fuzzy finder. I thought this project was closest to that and added my usecase to it.
|
I'm happy to include this. I'm sure some people would find it useful. |
Awesome, thanks!
|
The format shown to the user is slightly modified, see here the difference:
Before:
After:
This means that
RESULT
is modified as well. There is no colon in there, which means that we have to check whether the string begins with a/
. If it does,RESULT
is a path. If not, it must be a session. This has two downsides:It might not work on Windows, since a path probably does not start with
/
on Windows. I do not know how Windows paths work (do they start with\\
, Or withC:\
?), and I cannot test it.If the
session_name
starts with/
, the check fails because we assume that it is a path instead. This last part I have let it slide, since the current script is also not really forgiving if thesession_name
contains a space (and anothersession_name
exists with the first word as beginning as well).