Looking for Pro-Tips with tmux


#1

As part of the task of setting up a decent working environment on my mac, I picked up on @io_io comment about tmux. I’ve read up on it and it seems to meet my needs for creating a number of themed, multi-windowed/panelled sessions.

I want to have session for Python coding that is one full screen view, where I run Vim on half the screen, and divide the second half in tow horizontally, with a terminal in one panel and python running for hacking about below.

I’ve not got my Mac with me to play about with this today, but before I go home and try, and pro-tips on the set up? I’ve also read you can map Vim commands to tmux which sounds neat.


#2

Hi, take a look at this video, it helps:


#3

Love the way he gets brain lock at 31 mins! Thanks @io_io


#4

I haven’t really tried tmux. Always used screen and even that I don’t use too much. Maybe I should switch to it? What do you all like about it?


#5

Both VS Code and Primalscript each have different issues. Trying to fit a cmdline and the screen at the same time is a PITA for several reasons.

  1. tmux - 3 panels, editor, cmdline, and python repl. I like it.
  2. tmux - rotating the windows around is brilliant. Both VS Code and Primalscript suck when switching from monitor to laptop screen and vice versa. Need to move cmd window around so editor is right size.
  3. Hotkey switching between panes better than VS Code or Primal Script.
    I would like the ability to enlarge the text in only 1 pane at a time. But as it is a character based view that would not be possible. so the graphical editors with that round.

Of course to use tmux I would need to use vim or emacs. Quite the learning curve.
Matty


#6

I learned enough about it to suit my needs. It has many features. What I persoanlly like is I can have more windows. I can think of them as workspaces. I keep one for LMPTHW, one for bash, one for whatever else I am coding - web pages etc.
They are easy to navigate. Just do [prefix] + P you move to the previous window. Do [prefix] + N go to the next window.
Plus the panes… I always have up pane and down pane. The up pane is for my vim sessions. Open a file then use vim splits and edit 2 or 3 or 4 files.
Don’t know much about screen, I guess you have something similar, never tried it. The thing is I just saw Alex using tmux and loved it.
See the vid I linked to above.
It paints the picture very well, see if it adds something to screen or not.
I personally got used to it and love using it.
So this more windows thingie is called a session. You can also have more sessions if you wanted. Fire up session named “x”. You use tmux new -s [session name] and tmux will name it and remember it for you.
If you want to close it just do [prefix] + D and you detach from it.
When you leave your terminal on and come back to the session, do tmux -t [session name] -attach and it opens your x session. You can do tmux kill -session [session name]
A feature I would have adored would have been remember that session for how long I want
Say my battery dies, I want to re-attach to the last session. There’s no way to do that. It only works if you have your terminal on.
Read that they made a plugin for this, but some said it was quite buggy and i personally don’t want to install all kind of stuff on my laptop just because.
You can rotate content through the panes with [prefix] + hold CTRL down + o
resize panes, toggle through them, etc.
Another thingie I love is looks related: using powerline font … oh em gee, looks yummy!
It’s a bit confusing to install powerline, but once the nerves calmed down you will love it :smiley:


#7

Not sure about screen as I’ve only just discovered this but as I’ve been playing about with this, I find it meets my needs well. I leave a session running with my panes as I like it. As @io_io says, I love being able to fullscreen the terminal and then just run the last session.

tmux a #

For my working environment this is great. It means when I’m working I am less likely to get distracted by toggling windows. I just need to add Vim mappings (and maybe some other theme) but one command and I’m ready to go.

@zedshaw in the earlier days, I sometimes found when watching the videos or seminars I get lost when you are jumping between windows. (Also because I had no idea what you were typing - and it turned out to be vi commands!) For me, having one big view is much easier to follow.

I was going to create a session for general coding, one for seminar, one more hack orientated. And just call them on demand. Sweet.

In the example below I find that cycling through the windows gets distracting as I have other things open (like Mail, web, etc) that I’ll get caught by. Or I cycle 3 times through everything!

There is no opportunity or temptation in the example below. If I toggle, its consciously to do something else. And that can only happen when my Tide timer goes off.


#8

That’s interesting @gpkesley, you’re saying that if I turned on keystroke display you’d have an easier time? To me that seemed like so much noise it was too distracting, but maybe I can figure out how to turn it on again in the next video. Every time I try to display the keystrokes it just goes badly.


#9

@zedshaw Not the keystrokes, the toggling through windows. Took a second or two to recognise which windows we were in, then I’ve missed the first line of code.

When I say I had no idea what you were typing, I mean I could see some commands but didn’t recognise them. I think :fg was used a lot.

I think it’s just the side effect of being a pro. You do stuff so naturally that it is inevitably very fast. I’m cool with it now. (And can always rewind too!)


#10

So I got some keystrokes logging going in the new JS videos and I’ll use that tomorrow in the first Vim School seminar. Now, I have tried to make it a little easier to see what window I’ve switched to, but there doesn’t seem to be much of a way to “flash” a window so you know where to look. I’ll see if I can find something for windows 10.


#11

This is how my usual setup looks. What I love best about tmux is the fact that I can edit and run code in the same window.


#12

Do you ever experience problems with ctrl-key combinations conflicting between tmux and vim or any other programs?


#13

I e not used either significantly but Ctrl-b was immediately clashing. For me it’s okay as tmux takes precedence which is the ordering I’d prefer.


#14

None, but my key combos are different.