Tmux Part 1: Introduction

Introduction Tmux is the "terminal multiplexer," which in the creator's own words means: It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different term...
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/tmux-introduction

Hi Chris,

Nice video. Due to a poor Internet connection, I prefer to download the video and then watch it without the incovenience of the buffering.

My question is how do I move to the next step on the trails if I watch the video off-line?

My suggestion is to add some Q&A to each part of the tutorial. Correct answers should move the student to the next step on the trails. What do you think?

I think you just need to scrub the video past the 80% mark after you start it playing.

That’s not ideal, but it should work.

Tmux is messing up my vim colors for some reason. I found a fix, but it still is a bit off making it impossible to see visible whitespace and columns. I added this line to my ~/.zshrc file.

export TERM="xterm-256color"

Source

Does anybody else have a better solution?

I had the same issue but I found the solution in the following step :wink:

@blainesch @naoufalmed is right that you can find the TERM answer in the 2nd video, but for your and any other searcher’s benefit I’ll add the answer here as well. You want to set the default-terminal option in your .tmux.conf file:

set-option -g default-terminal "screen-256color"

Great video, thanks. Tmux is obviously useful – but, strictly for local development, is there a compelling reason I should prefer it to iTerm split panes and tabs? Basically, an iTerm pane == a tmux pane, and an iTerm tab == a tmux window, right? I’ve googled a bit but haven’t found any real arguments in favor of tmux over iTerm’s native functionality (which I realize can be configured to use tmux anyway, but doesn’t have to), except the argument that accidentally closing iTerm will destroy a session that would be persisted if I were using tmux – true, but I don’t really have a problem with accidentally closing iTerm. There must be more compelling reasons to use tmux than that. What am I missing?

HI @captain_zoom, the reason I use tmux over native iterm splits is two fold:

  1. While iterm is a great piece of software (that I use and love), I prefer to rely on open source tools for my core workflows
  2. I am able to interact with and configure tmux to better match my workflows. Video 4 on Vim tmux integration is a good example of how I leverage the interactive nature of tmux.

Splits and windows are a big part of tmux, but there is much more to it and I find it gives me room to adapt to my desired workflows.

@christoomey

Can you expand upon the reasons to setting the caps lock key to CTRL?

My first concern is…it doesn’t seem to be properly applying Caps Lock functionality to the CTRL key, even though, I’ve updated the system preferences as you’ve show. If I hold CTRL and type the letter t, it will still type a lowercase t. If I do the following key strokes → ctrl t ctrl t ctrl t, I will receive ttt, where I would expect the result to be tTt or TtT.

My second concern is… I don’t really know how it would help me keep my fingers on the home row, as I functioned with the CapsLock key with it’s normal functionality for a few months now, and it seemed to work fine.

Thanks for your time.

Hi @thedanotto, not sure if I’m reading your question wrong, but it sounds like you might have it backwards.

The goal is to gain more easy access to the Ctrl key, so we are making Capslock function as control. With this configuration, the left pinky can just slide out a bit further to the left to get a Ctrl key.

Hope that clarifies.

Hi @christoomey !

I was wondering about it being not advisable to have multiple instances of Vim during a single session. Specifically, could you be using Vim to edit a ruby file and simultaneously be using it to edit its relative spec file in another pane? Why might this be a bad idea?

Thanks!

Hi @DaisyMolving, I almost always have more than one Vim “window” open and am working with multiple files, for instance a spec file and the corresponding implementation file.

What we recommend agains is opening more than one Vim instance, aka a whole nother Vim started up.

You can see a bit more about the nomenclature for Vim here: Windows & Tabs | Online Video Tutorial by thoughtbot.

The reason you’ll want to avoid this is that you can make conflicting edits between two different Vim instances. Instead, you can use one Vim instance and take advantage of its windows and tabs to arrange multiple files, and Vim will automatically keep things in sync.

I’m curious, is there any technical reason for binding the prefix to Ctrl-a instead of Ctrl-b? I find it really awkward: I have Caps Lock mapped to Control, so pressing Ctrl-a means I need to move my left pinky to Caps Lock then hit ‘a’ with my ring finger, rather than the pinky as the normal motion would be.

@andyw8 No technical reason that I know of. I believe the main reason is historical, a throwback to screen. That said, I use C-s as my prefix since it is not useful, a bit more comfortable with CapsLock → Ctrl, and C-a is already mapped as beginning-of-line which is super useful.

I actually use Space as my Vim leader and C-Space as my tmux prefix. It doesn’t overwrite any useful bindings and requires very little movement to reach. I’d highly recommend you consider it!

@christoomey oops, I must have reading another page at the same time which was talking about using C-a. C-s certainly seems easier to type.

@rglassett nice idea. I also use Space in vim. I’ll give this a try.

Seems like C-b + shift+% is not working for me to split. I checked the man page and it says these are the prefixes. Did anybody face the same scenario. I have not created any tmux conf file though. tmux split-window worked for me though

Correct key is C-b + %. Are you sure you’re pressing % key after releasing C-b key? I know thread is old, but may be helpful for future reader, you need to press % key after releasing C-b key.