Hacker News new | ask | show | jobs
by bdowling 1612 days ago
> I do wish it was easier to select text from the terminal screen without using the mouse.

Check out TMUX. TMUX has a copy mode that can be used to navigate the scrollback buffer for any TMUX window/pane and select and copy text. By default, that text is copied to a TMUX paste buffer, but can be copied to the system buffer using a simple command (e.g., `tmux show-buffer | pbcopy` on macOS or `tmux show-buffer | xsel -b` on Linux/X11). You can set that command to run automatically when you copy, which saves a step if you do it often.

Also, if you enable vi keys in TMUX (e.g., add `set-window-option -g mode-keys vi` to ~/.tmux.conf), then you can navigate copy mode using vi navigation keys, including '/' and '?' for search within the scrollback buffer.

2 comments

Alacritty has a similar thing built-in, without tmux if someone doesn't like it for some reason.
This kind of copy and paste is a bummer though since it isn’t aware of word wrapping.
I just checked. TMUX does not insert newlines if there were no newlines in the buffer. That's usually what you want.
Maybe it varies by version, but I get this behavior all the time.
If you are copying from a text-mode app that does its own word-wrapping by inserting newlines or moving the insertion point, then it may not be possible for TMUX to undo that. Copying from shell output like `cat somefile` or `wget something`, however, works like it's supposed to.