Live data from Hacker News

Using tmux properly

danielallendeutsch.com

101–110 of 218 posts

Re: Using tmux properly

#101
post #60

Earlier quoted context omitted.

The problem is, my terminal already has a concept of scrolling, and its own concept of a buffer, with its own concept of keeping unlimited contents based on available memory, etc. I've never seen a tmux setup that doesn't fail horribly when these two concepts collide (I can't cmd-f search the buffer for interesting things, I don't get a scroll bar on the right that shows me how far up the buffer I am, scroll accelera…

> The problem is, my terminal already has a concept of scrolling, and its own concept of a buffer, with its own concept of keeping unlimited contents based on available memory, etc. Perhaps try iTerm2 (for Mac) native tmux integration. You can have tmux panes and split panes that are (and behave like) regular terminal panes and tabs.

"You can have tmux panes and split panes that are (and behave like) regular terminal panes and tabs."

What's the advantage of that exactly?

Re: Using tmux properly

#104
post #27
post #25

Earlier quoted context omitted.

Sessions are the killer feature for me. I have a session for each project I work on and can have all my tabs, panes, vim, etc set up and switch between them at any time. Sessions can be persisted so that even if I reboot my machine all my project workspace configurations are saved and ready to go.

How do you persist sessions between reboots?

I haven't used it, but there's a plugin which allows for this behavior: https://github.com/tmux-plugins/tmux-resurrect

Re: Using tmux properly

#105

The big problem I always have with tmux is that is messes up all of the colors in my Vim.

You need to set your tmux.conf to use the correct term type. For modern distributions it should be

set -g default-terminal "tmux-256color"

You also need to make sure tmux understands that your terminal supports true color mode. Set the following if e.g. using gnome terminal (which calls itself xterm-256color in $TERM)

set-option -ga terminal-overrides ",256col:Tc"

You'll need to reset $TERM to something more standard if you plan to SSH to older systems, though. I have a shell function that wraps SSH and sets the term type to screen for when I log into old systems.

Re: Using tmux properly

#106
post #66
post #61

Earlier quoted context omitted.

I disagree. I want to select with the mouse and touch type with the keyboard. And "doing it faster" is never a concern. As a programmer I write about 5% of what I could type in the same time as a secretary or accountant. Most of the work is thinking. Plus, the occasional chance to get your hands off of the rigid (and carpal tunnel inducing) pose on the keyboard and move them to the mouse, or vice versa, is welcome. I…

k I still prefer not using the mouse for a basic operation like scrolling, thank you.

I myself prefer to scroll with the keyboard in tmux, but for moving the cursor and selecting text, tmux has a very, very long way to go before being optimally efficient and useful in this regard.

The kings of keyboard-based cursor movement and text selection are vim and emacs, both of which have a very rich and powerful toolbox of techniques and plugins that help the user do that quickly and efficiently.

For example, emacs has plugins like ace-jump-mode which lets you jump the cursor to any precise position on the screen by typing just one or two keystrokes. vim has similar plugins, like easy-motion and precisejump.

vim and emacs also have quick ways to select words, sentences, paragraphs, functions, lines, logical and visual blocks, the entire document, etc. This includes having full access to rich and powerful regex text matching, which can be used for selection.

In contrast to emacs and vim, when I try to move my cursor and select text in tmux, I feel crippled. So sometimes I do succumb to the temptation of using the mouse to select text in tmux, despite being quite comfortable and satisfied in using the keyboard exclusively in vim and emacs.

Re: Using tmux properly

#107
post #51

Earlier quoted context omitted.

It gets worse when you work in ops and are constantly needing to remote into servers and you regularly have tmux within a tmux within a tmux... Littering config files across the datacenter just isn't an option.

I learned to give up making things exactly to my liking and learn to use the default key bindings. Now I can log into any machine and be 100% productive.

I consider myself a power Emacs user, I have a sizeable Emacs configuration, but when I connect to servers, I just use vi. Simpler, faster, less fuss.

Re: Using tmux properly

#108
After experimenting with mosh, tmux, screen, etc I've finally found my ideal ssh setup. At work I do development on my Mac and run builds on a cloud desktop. My Setup:

1. Unison for file-sync (https://www.cis.upenn.edu/~bcpierce/unison/)

2. iTerm on Mac

3. AutoSSH for more durable SSH sessions (ex. close laptop & reopen at home) - http://www.harding.motd.ca/autossh/

4. tmux -CC command to attach to tmux session with iTerm Tmux integration. This is the killer feature, it treats a tmux session as a native iTerm window. This means all of the 'learning' you previously had to do with Tmux is nearly non-existent (copy / paste, switching tabs, etc). My biggest annoyance with TMux was the copy / paste special handling. Huge productivity loss.

All-together it looks something like this: Open iTerm. autossh -t myRemoteHost "tmux -CC -A"

Instantly have a _fairly_ durable terminal session on my remote desktop.

Re: Using tmux properly

#109
post #68
post #64

Earlier quoted context omitted.

I use screen, and in my book the choice of ^A for the default escape is a giant WTF, and remapping that is the first thing I do on a new account before starting to use screen (I use ^o, for no particular reason I suppose except it's not used by anything else I use). Don't the screen developers ever need to go to the beginning of a line in the shell or editor?

> Don't the screen developers ever need to go to the beginning of a line in the shell or editor? C-a a. Using emacs with screen for many years, this is almost automatic for me.

When not using tmux/screen, the complete invocation is C-a a M-x roll-eyes RET Backspace.

Re: Using tmux properly

#110

So this may mark me out as different, but apart from persistent remote connections, I've never really felt the need for screen/tmux. I've been trying to figure out what the fuss is about, and I still really don't understand (apart from persistence and screen sharing.) When I want multiple terminals, I just fire up another terminal window and hey presto, jobs a goodun. I have a fairly high res screen and small fonts,…

The problem with opening multiple terminals is that you will eventually be slowed down in your workflow. Say you want to switch to a particular terminal, and you have more than 10 terminals running. You either have to press CTRL+Tab a few times (5 times on average for 10 terminals), or switch using the mouse, both of which are slow. Another problem is working remotely. If you connect to a remote server, and you need…

I had this problem, although I found after I started using a tiling window manager that I gravitated back from screen (which I used obsessively) to workspaces with a fairly small (usually two, sometimes three) of xterms running. I might have a total of six running, but they're on three workspaces, and the workspaces are conceptually discreet.

Tab cycling through more than 3 terminals got to be very tedious, but it also often got to be more difficult with the multiplexer to remember the absolute ids of terminals (in cases where I was opening a bunch of them to debug a problem) than it was to visually spot the one I wanted when I had them grouped into workspaces whose ids have meaning to me.

The remote thing you mention definitely gets to be a nuisance; usually when I'm debugging a remote machine, I open an xmonad workspace and on it a couple of terminals. It feels chintzy to ssh twice, but it's also weird to go from one set of terminal selection commands (xmonad's) to another (tmux's).

Anyway this probably sounds like I'm disagreeing, I totally agree but the tiling WM's threw a wrench into my thinking about being able to absolutely select specific terminals.

Post reply on HN