Open zenny opened 1 month ago
Hi @zenny , thank you for the issue and sorry for the delay
I glanced through the upstream issue you linked, and I'm not sure exactly what we're trying to achieve.
I'm busy these days as well and don't actively update this repo (as you can say by looking at the commit history).
That being said, if you'd be kind to elaborate, I'll try my best to look into it
Hi @zenny , thank you for the issue and sorry for the delay
I glanced through the upstream issue you linked, and I'm not sure exactly what we're trying to achieve.
I'm busy these days as well and don't actively update this repo (as you can say by looking at the commit history).
That being said, if you'd be kind to elaborate, I'll try my best to look into it
@farzadmf So nice of you to reply despite your busy schedule.
To make things clear, let me put this way:
Let us say I am working in two workspaces, say 1 and 5. I want to switch between 1 and 5 without using M-=
as @jabirali kindly advises as a feature of tmux. What I want to achieve is go to worspace 5 from workspace 1 by pressing M-5
and if I have to immediately switch to in between the last window (5) and current window (1), I prefer to press M-5
again to go back and forth between 1 and 5. This might make life simpler to everyone I guess than using a different keybindings like M-=
. I do the same kind of toggle in herbstluftwm using s-n
(n is workspace number here), fyi.
Thanks for your attention, and have a nice week, Cheers, /zenny
Hi @farzadmf,
Hope you're doing well :).
Basically, the function bind_switch(n)
implemented in the upstream tmux-tilish
(bound to M-1
to M-0
by default) currently implements this pseudocode to switch to workspace number $n$ whether it exists or not:
bind_switch(n):
if workspace_exists(n):
select_workspace(n)
else:
new_workspace(n)
My understanding is that @zenny wants the following pseudocode to be implemented instead:
bind_switch(n):
if workspace_exists(n):
if current_workspace() != n:
select_workspace(n)
else:
select_last_workspace()
else:
new_workspace(n)
Regards, Ali.
Hi @farzadmf,
Hope you're doing well :).
Basically, the function
bind_switch(n)
implemented in the upstreamtmux-tilish
(bound toM-1
toM-0
by default) currently implements this pseudocode to switch to workspace number n whether it exists or not:bind_switch(n): if workspace_exists(n): select_workspace(n) else: new_workspace(n)
My understanding is that @zenny wants the following pseudocode to be implemented instead:
bind_switch(n): if workspace_exists(n): if current_workspace() != n: select_workspace(n) else: select_last_workspace() else: new_workspace(n)
Regards, Ali.
Thanks @jabirali, btw where would one append the bind_switch
pseudocode?
Hi @zenny,
Basically, tmux-tilish
is implemented as a shell script, which uses tmux
commands to essentially remote control tmux
. For instance, typing tmux bind -n M-1 ...
in a shell will tell tmux
to define a keybinding M-1
that should do ...
. To avoid hardcoding too much of those tmux
commands, the keybindings are defined via reusable shell functions: e.g. M-1
to M-9
all switch to a window, so instead of hardcoding those keybindings, they are set by the bind_switch
shell function as shown here in the code. The bind_switch
function itself is defined here in the code.
Currently, that function is a bit hairy: it's a shell command that asks tmux
to bind a key to a shell command that asks tmux to change the current workspace... and if that command fails, we assume that it's because the workspace we're trying to switch to doesn't exist, and therefore decide create that workspace instead. The code isn't that clean, but I don't know of a prettier way to do this, and the current code has been tested to work well across many tmux
versions :).
But basically, that's where we'd have to insert the new pseudocode to get this working! In practice, that means that we either need a cleaner implementation of bind_switch
which is easier to extend, or might need to nest more if-shell
things inside each other to "hack in" the desired logic.
Hi @farzadmf ,
I came to learn about this fork of https://github.com/jabirali/tmux-tilish from your post (https://github.com/jabirali/tmux-tilish/issues/11).
Thanks to you and @jabirali.
Would not it be very useful to add up the toggle between current and last window and cycling which could be immensely helpful to switch in order to compare between the contents in two tabs with the same
M-n
key?Would you mind having a look at https://github.com/jabirali/tmux-tilish/issues/20?
Thanks in advance and have a nice weekend.
Cheers, /z