Live data from Hacker News

Using tmux properly

danielallendeutsch.com

181–190 of 218 posts

Re: Using tmux properly

#181
post #124
post #87

Earlier quoted context omitted.

If the only time you see a production box is when it's on fire, I think there's an organizational problem. Occasionally acting as third-line support means real production disasters aren't an unfamiliar zone.

In the "immutable architecture" style, the only time you see a shell on a production box should be when it's on fire (and even then, only if you need to do some "perimortem" debugging because the problem keeps reoccurring even when you just blow the server's state away with a reboot, and nothing in the "postmortem" logs tell you enough to diagnose or even know what more logging you should add.)

I'd hope an immutable architecture wouldn't break inside the box, since that would indicate it mutated :) And if it did, you'd just blow it away and replace it.

At that level, it's the interactions with different components that can break down, and the tools you use are more about testing configured interactions. Also, bad data. That bit necessarily mutates.

I'm a big fan of developing in a similar environment to production, so that the debugging tools and interaction are familiar long before an emergency. At our company, we develop on Linux and deploy on Linux.

Re: Using tmux properly

#182

I love Tmux, I just can't seem to wrap my head on how to COPY and PASTE something lol. Anyone have any step, by step tutorial for how to copy and paste like VIM? I would like to be able to see what is being copied just like in VIM's visual mode. Like If I can copy some code in VIM and then go to paste in another REPL pane in TMUX then that would be my ideal goal!

By default it's:

    C-b [   Start copy mode
C stands for CTRL, by the way.

This allows you to scroll up in the window and place the cursor where you want to start copying, then:

    C-SPACE Set mark
This sets the mark for copying, then you can move around and what will be copied will be hilighted with a background color.

    M-w     Copy selection
This copies the selection. Incidentally, M stands for "meta" and is nearly always usable with ESC, but often ALT will work in many terminals (some need a setting to enable it).

To paste, go to the buffer you want to paste into and then:

    C-b ]    Paste!

Re: Using tmux properly

#183
post #51

Earlier quoted context omitted.

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.

[deleted]

Re: Using tmux properly

#184
post #145

Earlier quoted context omitted.

A friend suggested remapping the Screen command key to ` (backquote), and it changed my life. Maybe it's because I grew up using Esc key combos a lot (terminals with broken/missing meta keys), but it feels natural to treat it like another modifier key there on the left edge of the keyboard.

I did that as well, and it was Great and Good and obviously the Right Thing — right up until I pasted in a some shell code which used `` instead of $(). Never again. These days I use C-z for tmux. It works, and C-z z is easy enough to type when I want to put something in the background.

I'm a committed (interpret that as you like) tcsh user, so yeah, that keybinding gets in the way. On the flip side, it's gotten me out of the habit of blindly copying/pasting shell code, which is a security win, right? ;)

Re: Using tmux properly

#185
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. 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?

Proper fucking scrolling?

Less terminal behavior that needs to be multiplexed by tmux?

More integration with other iTerm features (instead of tmux panes being agnostic to them)?

Re: Using tmux properly

#186
I use ... Screen on production servers. ... Screen has the lightest footprint

dtach, which is what I use on production servers even though it usually doesn't come standard, probably has the lightest footprint if you just want to return to some screen later. It doesn't maintain history, however, the screen is redrawn, if possible, on reattach.

Otherwise, yes. Both tmux and the book are great (if you don't mind getting drawn into wasting time on customizing the status bar and such).

Re: Using tmux properly

#187

Earlier quoted context omitted.

At my employer, we have unix accounts for every employee, and the system automatically synchronizes your dotfiles to each server.

On a production server? You're doing it wrong.

Why? This lets admins log in as themselves (leaving an auditable trail) with access to their own dotfiles to debug and analyze on the fly. Even with ex. Ansible for managing and ex. Nagios for monitoring, being able to use a shell to diagnose and fix novel issues is invaluble. If you've got a better solution, please do share. (Sincerely: if you can make my job easier, I'm happy to listen)

Re: Using tmux properly

#188
post #146

Earlier quoted context omitted.

"having non-standard configuration is inherently more complex" I disagree. It can be more complex, but it is not at all inherent. If I configure my shell, my editor, my whatever software to work more like other software I use (keybindings, etc), I can actually make it less complex for me, because copying over a few config files on those rare occassions I need to is much faster than trying to learn a whole new set of…

fish shell dev here. > People have different preferences on how things work, and some of the choices on how to do things are mutually exculsive. Yes! But asking the user to manually configure the system is a lame way to accomodate those preferences. It's better if the software can learn from the user. For example, if the user runs a certain command frequently, don't wait for the user to define an alias, just suggest…

I appreciate that you call out keybindings as a likely exception, but particularly in the shell, keybindings are 90% of my configuration! For some settings I'm sure there are sane defaults, but if programs don't know whether I prefer vim or emacs then they're going to have a bad time.

Re: Using tmux properly

#189
post #44
post #42

Earlier quoted context omitted.

The thing about tmux bindings is that, as far as I know, very few people like the defaults. I've taken the approach of 'learn the defaults' for vim, but on tmux that simply won't stand because the defaults have so much room for improvement. Pretty much everything I've read on tmux suggests the - and | bindings for window splits, same goes for hjkl bindings for movement. Adding these bindings would go a long way towar…

Yeah, I learned screen defaults, so ^A is far too strong of a habit to change.

That, and switching to the vi-like keybindings for copy mode, are the only two things I change. And even so, I can and do use an unconfigured tmux with only minor irritation. Configuration just looks like an elaborate way to make sure you're unable to use other people's systems.

Re: Using tmux properly

#190
post #145

Earlier quoted context omitted.

I did that as well, and it was Great and Good and obviously the Right Thing — right up until I pasted in a some shell code which used `` instead of $(). Never again. These days I use C-z for tmux. It works, and C-z z is easy enough to type when I want to put something in the background.

I'm a committed (interpret that as you like) tcsh user, so yeah, that keybinding gets in the way. On the flip side, it's gotten me out of the habit of blindly copying/pasting shell code, which is a security win, right? ;)

I'm going to interpret that as "committed to an institution" :) Tcsh makes my brain hurt.
Post reply on HN