Skip to content

Keyboard Select And Copy commands. #947

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

Open
casonadams opened this issue Dec 16, 2021 · 12 comments
Open

Keyboard Select And Copy commands. #947

casonadams opened this issue Dec 16, 2021 · 12 comments
Labels
action Issues related to actions

Comments

@casonadams
Copy link
Contributor

Would be nice to copy text via the keyboard rather then having to use the mouse.

@a-kenji a-kenji added the action Issues related to actions label Mar 24, 2022
@xJonathanLEI
Copy link
Contributor

Looks like this issue is not getting the attention it deserves.

Zellij is for heavy users of terminals. I'm pretty sure many of them, like me, prefer TUI applications because it's just much easier and faster to just keep the hands on the keyboard. Having to select text by mouse just for copying things seems a bit counter-intuitive to me.

Not to mention some devices don't come with a mouse:

  • machines running OS without GUI (e.g. remote server)
  • Android phones, except when connected with an external mouse

Or maybe it's already implemented and I somehow missed it? Sorry if that's the case.

@xJonathanLEI
Copy link
Contributor

xJonathanLEI commented Nov 3, 2022

One workaround I can think of is to edit the current buffer with an editor (e.g. Helix) that supports copying text to Zellij. It's a pretty bad workaround tho IMO. Too many steps:

  • enter search mode
  • open buffer editor (and wait for it to load if buffer is large)
  • navigate to the last line (G in Vim and ge in Helix)
  • select text
  • yank to system clipboard (i.e. Zellij)
  • exit editor (:q<enter>)

I wish I can have something like the copy mode in tmux.

@imsnif
Copy link
Member

imsnif commented Nov 4, 2022

One workaround I can think of is to edit the current buffer with an editor (e.g. Helix) that supports copying text to Zellij. It's a pretty bad workaround tho IMO. Too many steps:

This is the zellij way of doing this. IMO it's a much better and more natural way, allowing you to outsource to your editor rather than learning a whole new interface (or having to deal with an interface that is similar to one you know, eg. vim-like keys, but is not feature complete for you and will never be without reimplementing vim completely).

It should however involve exactly the same amount of keyspresses as copy mode in tmux:

* enter search mode 
* open buffer editor (and wait for it to load if buffer is large)

These both have to happen for tmux as well. The wait is kind of up to your editor though. I use vim and for me its always instantaneous even with the maximum default scrollbuffer.

* navigate to the last line (`G` in Vim and `ge` in Helix)

This doesn't happen in any editor that supports opening a file to a specific line. Iirc this wasn't implemented in helix at the time I wrote this feature - would be happy to also make it work with helix once they add support for this.

* select text
* yank to system clipboard (i.e. Zellij)
* exit editor (`:q<enter>`)

All of these would happen in a copy-mode like editor as well.

@xJonathanLEI
Copy link
Contributor

Thanks for the reply! It's very detailed! Sorry I only tested the flow in Helix and assumed that it's the same in other editors. I will look into Helix to see if that's supported.

I guess in that case the only difference would be the extra step to exit the editor in the end, but that's much better already.

@imsnif
Copy link
Member

imsnif commented Nov 4, 2022

I guess in that case the only difference would be the extra step to exit the editor in the end, but that's much better already.

I think you can totally rig most editors to exit after a copy. I'll leave this as an exercise for the reader :)

@magthe
Copy link

magthe commented Sep 10, 2023

At first I was a bit disappointed when I found this issue and read the discussion.

I'm even thinking that given the view that Zellij shouldn't provide keyboard-driven select-copy, why not limit it even further? Why not only expose the history/scrollback via EditScrollback and let the user hook it up to whatever external tool she/he wants? (Maybe through a slightly more general command OpenScrollback that takes the tool/command as an argument?)

So, I decided to try Zellij out, with a config with a binding to EditScrollback as the only way to interact with the scrollback: https://magnus.therning.org/2023-09-10-using-emacs-for-the-scrollback-in-terminal-multiplexers.html

@chriselrod
Copy link

chriselrod commented Sep 10, 2023

@magthe re-starting emacs quickly, why not use an emacs server, and then edit with emacsclient?

@xJonathanLEI
Copy link
Contributor

Note

I totally understand Zellij and tmux are two different projects and I'm not implying that Zellij should become tmux. I'm using tmux here only to facilitate demonstrating the use case.)

Now that this old thread is dug out... Tbh this is still one of main things that deter me from daily driving with Zellij. I understand that it's the maintainer's decision to not implement something like tmux's copy mode, and I respect that. However, apart from the extra keystroke, the actual main downside for me is the context switch that comes with this approach.

With something like tmux's copy mode, you act on what's on your screen, with all the text positioning and colors in place. Once the buffer is sent to the editor, the positioning can change (due to bufferlines and stuff), and the colors are most definitely lost. There's some mental effort to refocus on where you wanted to work on before entering this mode. And it's another context switch after you finish copying and exit the editor.

@magthe
Copy link

magthe commented Sep 11, 2023

@magthe re-starting emacs quickly, why not use an emacs server, and then edit with emacsclient?

Mainly because it's fast enough without the added complexity 😃 However, that's very much off-topic for this ticket.

@magthe
Copy link

magthe commented Sep 11, 2023

Now that this old thread is dug out... Tbh this is still one of main things that deter me from daily driving with Zellij. I understand that it's the maintainer's decision to not implement something like tmux's copy mode, and I respect that. However, apart from the extra keystroke, the actual main downside for me is the context switch that comes with this approach.

With something like tmux's copy mode, you act on what's on your screen, with all the text positioning and colors in place. Once the buffer is sent to the editor, the positioning can change (due to bufferlines and stuff), and the colors are most definitely lost. There's some mental effort to refocus on where you wanted to work on before entering this mode. And it's another context switch after you finish copying and exit the editor.

Yes, that's why I consider my setup an experiment for now. The upsides I see are:

  • Emacs is way more capable when it comes to searching, limiting what I see, as well as selecting what I want to copy, than tmux copy-mode is.
  • The keybindings in my minimal Emacs setup are close to those in my full Emacs setup, so there's a level of increased familiarity. (The tmux bindings are vi-like, but not identical AFAIU.)

As I'm not doing any searching at all using Zellij I can avoid losing context by just jumping to the end of the scrollback buffer on opening Emacs. When returning I jump back to the current command line, so that's exactly like when leaving copy-mode in tmux.

@sedlund
Copy link

sedlund commented Feb 5, 2024

@xJonathanLEI

With something like tmux's copy mode, you act on what's on your screen, with all the text positioning and colors in place. Once the buffer is sent to the editor, the positioning can change (due to bufferlines and stuff), and the colors are most definitely lost.

Interestingly in tmux there is a capture-pane -e which captures the ANSI escape sequences this can then be save-buffer filename.ans and then open in neovim with something like nvim +'terminal less -r filename.ans' +'set laststatus=0' +

This opens the buffer in (readonly in this example) with all the colors and glyphs and the status line disabled and cursor moved to the end to help preserve context.

I wonder if Zellij could also save the escape sequences to do something similar.

@greg-minshall
Copy link

i'll say this is one issue that keeps me from trying out zellij seriously.

i used to use tmux. but, i had some reliability issues with it. so, not i use gnu session, which is okay, but not as comfortable for me as tmux, or as zellij looks to be.

(one other thing for me would be being able to configure e.g., Unlock-first mode via the config file -- sorry if i have that wrong.)

nice looking system, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action Issues related to actions
Projects
None yet
Development

No branches or pull requests

8 participants