Live data from Hacker News

Tmux for Mere Mortals

zserge.com

41–50 of 171 posts

Re: Tmux for Mere Mortals

#41
post #40
post #9

Earlier quoted context omitted.

I’ve always done: > Mod+| for vertical split > Mod+- for horizontal split I’ve been using it like that for years, but haven’t seen it in too many places like that. It just feels super logical since the symbols look like the split!

Could not agree more. I throw in underscore and backslash for good measure too: bind-key | split-window -h bind-key \ split-window -h bind-key - split-window -v bind-key _ split-window -v

That’s it right there. I basically have the same thing. Worst comes to worst, Since they are visually so close, when I started, I never forgot what did what.

Re: Tmux for Mere Mortals

#42

Earlier quoted context omitted.

You can configure tmux to synchronize with the X clipboard, although it is somewhat fiddly because of how terminal emulators work. See this page: https://github.com/tmux/tmux/wiki/Clipboard In most terminal emulators you can also use Shift (or sometimes a different modifier) to bypass application mouse mode and have the terminal emulator handle the mouse event. Of course you can't copy out of the history with this, b…

> that is another limitation of terminal emulators. This seems more an excuse than a cause. When the "mouse mode" of tmux is off, the copy-paste mechanism works perfectly. There is no reason why this couldn't still be the case when the mouse mode is on. For example, tmux could enable the mouse only for scrolling and resizing the panes, while keeping the correct copy paste behavior intact. But it chooses not to.

[deleted]

Re: Tmux for Mere Mortals

#43
post #10

Spent too much time wonking a tmux config only realizing it was never going to work how I liked. You can't have it all with the mouse no matter your settings, there will always be a compromise. It also doesn't help that no one cites the version of tmux they wrote their configs for, nor that the configs are not backwards compatible with all versions of tmux for all settings. It's really clunky, but I went from tmux to…

Yes, the mouse situation in tmux is catastrophic. As much as I love tmux, I wonder what would it take that the program respects the usual copy-paste conventions like all the rest of X programs. You need to do two things, that are apparently impossible when tmux has "mouse enabled": 1. select some text in your xterm so that it gets copied 2. middle click on the xterm and your copied text (possibly from other window, w…

It works just like that if you press shift?

Re: Tmux for Mere Mortals

#44
post #26

After a few years in tmux, I actually moved back to just iterm2 (I'm always on osx). There are many new Iterm2 features over the last few years that make tmux unecessary IMO. - Iterm2 can now restore sessions, even partially after a reboot (attempts to recreate workspaces). This was the main benefit of tmux for me. - Iterm2 can also have a visual mode to browse your scrollback buffer, and there are some shortcuts sim…

iTerm2 also has tmux integration, which gives you all of these nice features when using tmux on a remote machine.

Re: Tmux for Mere Mortals

#45
post #26

After a few years in tmux, I actually moved back to just iterm2 (I'm always on osx). There are many new Iterm2 features over the last few years that make tmux unecessary IMO. - Iterm2 can now restore sessions, even partially after a reboot (attempts to recreate workspaces). This was the main benefit of tmux for me. - Iterm2 can also have a visual mode to browse your scrollback buffer, and there are some shortcuts sim…

Don't forget about iterm2's tmux integration. It makes both local tmux and tmux over ssh appear like regular tmux panes. No more bizarre keybindings and tmux configs - it just works.

Re: Tmux for Mere Mortals

#46
post #37
post #18

Earlier quoted context omitted.

> realizing it was never going to work how I liked. > You can't have it all with the mouse no matter your settings > so I went back to just using the cursor to move things around. These tools (vim, tmux, etc.) work great for mouseless setups. If you can get comfortable with a 100% keyboard control paradigm, it might work for you. I realize this might not be what you want, but if the statement "spend less time moving…

My biggest problem with "mouseless tmux" was copy-paste. How do you deal with that?

A typical scrollback cut and paste workflow for me is via this P mapping. I'm lazy I just grab everything.

   bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S -32768 ; save-buffer %1 ; delete-buffer'
then it's all in a file you can work with in an editor of your choice

Re: Tmux for Mere Mortals

#47

Earlier quoted context omitted.

You can configure tmux to synchronize with the X clipboard, although it is somewhat fiddly because of how terminal emulators work. See this page: https://github.com/tmux/tmux/wiki/Clipboard In most terminal emulators you can also use Shift (or sometimes a different modifier) to bypass application mouse mode and have the terminal emulator handle the mouse event. Of course you can't copy out of the history with this, b…

> that is another limitation of terminal emulators. This seems more an excuse than a cause. When the "mouse mode" of tmux is off, the copy-paste mechanism works perfectly. There is no reason why this couldn't still be the case when the mouse mode is on. For example, tmux could enable the mouse only for scrolling and resizing the panes, while keeping the correct copy paste behavior intact. But it chooses not to.

No, this is not how it works. There is no terminal emulator that offers this kind of fine-grained mouse support. tmux can either turn the mouse on and handle everything (resize, scroll, copy and paste) itself, or it can leave it off and receive no mouse events.

Re: Tmux for Mere Mortals

#48
post #37
post #18

Earlier quoted context omitted.

> realizing it was never going to work how I liked. > You can't have it all with the mouse no matter your settings > so I went back to just using the cursor to move things around. These tools (vim, tmux, etc.) work great for mouseless setups. If you can get comfortable with a 100% keyboard control paradigm, it might work for you. I realize this might not be what you want, but if the statement "spend less time moving…

My biggest problem with "mouseless tmux" was copy-paste. How do you deal with that?

Make your own cheatsheet for bindings you need. This way you learn faster and optimize for your own needs. Tmux is exceptional mouseless, though personally I prefer combining with mouse.

With xclip, mouse and copy/paste can work over SSH-forwarded X-sessions with C-y and Enter from copy-mode-vi so:

  # For older versions of tmux:
  #setw -g mode-mouse on
  #set -g mouse-resize-pane on
  #set -g mouse-select-pane on
  #set -g mouse-select-window on
  # For newer versions of tmux:
  set -g mouse on
  bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; #send-keys -M'"
  bind -n WheelDownPane select-pane -t= \; send-keys -M

  set -g set-clipboard on
  # With xclip
  bind-key -n C-y run "tmux show-buffer | xclip -selection clipboard -i >/dev/null"
  #bind-key -n C-y run-shell "tmux save-buffer - | xclip -i -selection clipboard >/dev/null"
  # For tmux 2.4+
  bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -selection clipboard -i'
For Windows vcxsrv is the simplest and most fool-proof X-Windows server. Anything else on Windows may result in pain.

My preference is to reduce visual clutter in tmux by tweaking config and mostly just follow built-in bindings so workflow mostly works on standard tmux as well.

When clipboard fails between environments, sometimes multiple copy-ing, and then pasting into a text-editor helps (not a tmux issue, but clipboard-integrations).

Re: Tmux for Mere Mortals

#49
post #20

Earlier quoted context omitted.

The top reason I did start using tmux was because of how you can select text with the keyboard in copy mode (like visual in vim mode). Then I got the plugin tmux-plugins/tmux-yank which adds "y" command to copy the text. Also works with selection by mouse. I've run this setup now for something like 5 years across multiple tmux versions and OSes (Ubuntu and Arch) without any hiccups. But then I think tmux is a tool ge…

> The top reason I did start using tmux was because of how you can select text with the keyboard in copy mode (like visual in vim mode). Then I got the plugin tmux-plugins/tmux-yank which adds "y" command to copy the text. Also works with selection by mouse. Sure, but this is the internal "copy mode" of tmux, and is not useful to copy text in and out of your terminal.

> Then I got the plugin tmux-plugins/tmux-yank which adds "y" command to copy the text

tmux-yank copies whatever you selected to the system clipboard (xclip, clip.exe, etc.)

Re: Tmux for Mere Mortals

#50
post #37
post #18

Earlier quoted context omitted.

> realizing it was never going to work how I liked. > You can't have it all with the mouse no matter your settings > so I went back to just using the cursor to move things around. These tools (vim, tmux, etc.) work great for mouseless setups. If you can get comfortable with a 100% keyboard control paradigm, it might work for you. I realize this might not be what you want, but if the statement "spend less time moving…

My biggest problem with "mouseless tmux" was copy-paste. How do you deal with that?

I use Emacs copy & paste, or readline. I don't do a lot of copy & paste between different windows though. Paste in works adequately (terminal stuffs it into keyboard buffer) but may need a reformat if the mode has autoindent, while I zoom the window (C-b z) and turn off line numbers to copy out.

If formatting is super important, I paste into a file with cat > file, and read the file into Emacs. I can do the same in reverse for a big copy out, and transfer the file.

I do these things because I often use Emacs in a ssh session instead of tramp, because I'm coming from a different OS or need to use modes with sidecar executables, e.g. enh-ruby-mode.

Post reply on HN