News for hackers. Stuff that matters.
Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @11:17AM (#9505647)
For those who are just getting started with tmux: I advise looking around others' .tmux.conf files for some sensible settings. Like Vim, Tmux ships with a lot of powerful features disabled by default.

My absolute favorite has to be binding a hotkey to opening URLs in the current window [0]. See [1] for a small demo I just recorded.

To get started, here's my current config: [1]

[0]: https://github.com/jbnicolai/tmux/blob/master/.tmux.conf#L12...

[1]: http://recordit.co/vdxy09GpYG

[2]: https://github.com/jbnicolai/tmux/blob/master/.tmux.conf

Re:Tmux 2.0 released by victorquinn on Thursday May 07, 2015 @12:45PM (#9506392)
I wrote a book titled "Getting started with tmux" which can be a helpful guide for those who may want to get started.

http://gettingstartedwithtmux.com

(Sorry if the self plug is not cool, I'm happy to delete this comment if it's not ok but I figure the community may get use out of my work)

Re:Tmux 2.0 released by kbenson on Thursday May 07, 2015 @02:31PM (#9507208)
As long as the comment is useful and contributes, I think it's fair game. This definitely qualifies. That said, if it's not free, I personally would prefer that be mentioned, (and at the same time a link to a free sample chapter or equivalent if it exists would be useful).
Re:Tmux 2.0 released by hans_mueller on Thursday May 07, 2015 @01:37PM (#9506832)
90% of HackerNews is self plug ... so don't worry :)
Re:Tmux 2.0 released by jwhitlark on Thursday May 07, 2015 @05:40PM (#9508489)
It was quite a good book! It might be due for an update, what with tmux plugins and other new tools. I'd buy an updated version.
Re:Tmux 2.0 released by fsloth on Thursday May 07, 2015 @02:39PM (#9507270)
Thanks! It was most helpfull when I got to know tmux.
Re:Tmux 2.0 released by olalonde on Thursday May 07, 2015 @12:26PM (#9506254)
Here's mine: https://github.com/olalonde/dotfiles/blob/master/tmux.conf

One tweak I can't live without is having the same key bindings to seamlessly switch between tmux panes and Vim split windows. (https://gist.github.com/mislav/5189704)

TPM is also really useful for managing tmux plugins https://github.com/tmux-plugins/tpm.

My prefix key is Ctrl-Space. It's very convenient to press on the keyboard, I'm surprised to not see it used more widely (maybe because it's commonly bound to some OS utilities?).

Re:Tmux 2.0 released by saidajigumi on Thursday May 07, 2015 @02:52PM (#9507377)
> One tweak I can't live without is having the same key bindings to seamlessly switch between tmux panes and Vim split windows.

YES, THIS! Setting up directional pane navigation to work with both tmux and vim panes as first-class entities was a huge workflow boon for me as well. It was a significant change that helped kick my setup over into vim+tmux+zsh as IDE vs. merely a collection of separate parts.

It's worth noting that some relevant bits of @mislav's stuff has been packaged up nicely as a Vim plugin:

https://github.com/christoomey/vim-tmux-navigator

I also just noted that @tarruda (of neovim fame) chimed in on @mislav's gist with his own independently created version of the Vim-side of things. It looks worth comparing some of the implementation details from @tarruda's work, he's done some stuff to eliminate redraws in Vim, etc.

Re:Tmux 2.0 released by olalonde on Thursday May 07, 2015 @03:15PM (#9507536)
> It was a significant change that helped kick my setup over into vim+tmux+zsh as IDE vs. merely a collection of separate parts.

Same thing here :) I also set `tmux attach -t base || tmux new -s base` as my start command in iTerm which kind of forces me to use tmux windows/panes/sessions instead of iTerm tabs. It took a while to lose the habit of hitting `cmd-t` but was definitely worth it.

The thing that sucks now is that I'm really not sure which parts of my environment can be optimised further other than learning new Vim commands :)

Re:Tmux 2.0 released by saidajigumi on Wednesday May 13, 2015 @02:43PM (#9541095)
Heh, I have something similar, with a tmux session-start script[1] that's the first thing run by my default iTerm windows. It displays and lets me select from existing sessions via prompt tab completion. Or I can just enter a new session name at the prompt.

In iTerm, this would be a start command of:

    login -fp YOUR_USERNAME /Path/To/local/bin/mux --prompt
Or used directly from a normal command line (with zsh completion [2]) as:

    mux <session_name>
Apologies to tmuxinator users for conflicting with 'mux'; obviously feel free to rename it. This is really just a part of my personal setup vs. a formally published utility, and I don't use tmuxinator.

[1] https://github.com/jwhitley/tilde-local/blob/master/local/bi...

[2] https://github.com/jwhitley/zshrc/blob/master/.zfunctions/_m...

Re:Tmux 2.0 released by joepvd on Thursday May 07, 2015 @05:21PM (#9508385)
Honest question: Is there any benefit of using tmux over a proper tiling window manager? Or, why would I want to delegate some of the window manager tasks to a terminal emulator?
Re:Tmux 2.0 released by mikekchar on Friday May 08, 2015 @02:06AM (#9510204)
I use both a tiling window manager (xmonad) and tmux. The main reason I started using tmux was to do pair programming sharing the same terminal via ssh. If you pair program and have never tried this before, I highly recommend trying it. I live in Japan and even pair with people in London using tmux and vim. It's the next best thing to being there.

After I started getting used to using tmux, I found that my workflow naturally separated between things I'm doing on my terminal and things that require X (like my browser). These days I use a separate workspace for X apps and terminal (occasionally moving them around).

To make my life easy, I've added xmonad-like key bindings and window layout to tmux. Since other people are sharing:

https://github.com/ygt-mikekchar/dotfiles/blob/taka/home/.tm...

I often work while travelling and when I'm on the road I often don't bother cranking up X -- just work in the Linux console. Using tmux I barely notice a difference in my workflow and it helps extend the battery.

Re:Tmux 2.0 released by dkns on Thursday May 07, 2015 @05:54PM (#9508592)
For me it's having two different terminals connected to same tmux session. I use tiling window manager and work on two monitors. Sometimes there is some stuff that I'm working on on my main monitor but I want to have quick look at the terminal. Because I have two terminals opened on both monitors I can just switch to the other one, press ctrl+f(my prefix)+number and have exactly same window as in my main terminal.

For anyone wondering you can achieve above by typing tmux new-session -t and giving it number/name of your current session.

Also there are minor things that are nice. Like if you need to open another terminal instance in the same directory as you're currently in.

Re:Tmux 2.0 released by jwhitlark on Thursday May 07, 2015 @05:43PM (#9508514)
Yes, there's lots of value to tmux outside of "window management", even if you only use it locally. That said, lots of the value is using it remotely.
Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @02:17PM (#9507116)
I use <C-s> myself, but <C-Space> works just as well I suppose. Not bound to any OS utilities on OS X afaict.

Thank you so much for pointing me towards that vim+tmux gist!

Re:Tmux 2.0 released by danieloaks on Saturday May 09, 2015 @05:49PM (#9517821)
I use <C-s> for my local machine, and I make the servers I login to use <C-a>. I bind the caps-lock key to ctrl, so it works out pretty well, and lets me work with both local and remote contexts at the same time fairly nicely.
Re:Tmux 2.0 released by foobarqux on Thursday May 07, 2015 @09:27PM (#9509514)
C-Space sets the mark in emacs, which is a regularly used operation.
Re:Tmux 2.0 released by dezgeg on Thursday May 07, 2015 @01:53PM (#9506937)
> My absolute favorite has to be binding a hotkey to opening URLs in the current window.

I suppose this stops working if you SSH into some box and run tmux there? I've implemented something similar, but as an urxvt plugin instead, which avoids that limitation: http://www.cs.helsinki.fi/u/tmtynkky/urxvt.png (Once Alt-O is pressed, the hotkeys with the red background appear next to each link; pressing the hotkey opens the link in browser and copying to clipboard is also possible)

Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @02:14PM (#9507095)
You're absolutely correct, although I do all my terminal work locally in tmux as well (and often nest any remote work in a secondary remote session).

Liking the plugin you wrote!

Re:Tmux 2.0 released by lysis on Thursday May 07, 2015 @12:19PM (#9506184)
Why do you create a new window to maximize a pane [1] instead of using resize-pane -Z (mapped to bind-key z by default)?

[1]: https://github.com/jbnicolai/tmux/blob/master/.tmux.conf#L96

Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @02:18PM (#9507130)
Because <Leader-Z> didn't exist in the latest version of tmux at the time. I've removed it now though, thanks!
Re:Tmux 2.0 released by digitalzombie on Thursday May 07, 2015 @01:16PM (#9506663)
> Like Vim, Tmux ships with a lot of powerful features disabled by default.

lol, my tmux keys are basically model after vim. This is the book I used to learn tmux and has vim key settings:

https://pragprog.com/book/bhtmux/tmux

Re:Tmux 2.0 released by bphogan on Friday May 08, 2015 @12:57AM (#9510027)
Thanks for reading.
Re:Tmux 2.0 released by amjith on Thursday May 07, 2015 @12:08PM (#9506077)
Zoom/Unzoom is now part of default tmux.

<bind>z

So you can remove this line from your config:

https://github.com/jbnicolai/tmux/blob/master/.tmux.conf#L98

Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @12:19PM (#9506187)
You're absolutely right, thank you!
Re:Tmux 2.0 released by Jaepa on Thursday May 07, 2015 @11:22AM (#9505704)
You use ctl+s as your bind?
Re:Tmux 2.0 released by jkyle on Thursday May 07, 2015 @11:57AM (#9505976)
I use ctrl+s on my local config and I use ctrl+a on my remote tmux.conf's.

That way I can attach to a remote tmux in a local session and not produce a terminal muxing singularity that swallows worlds.

Re:Tmux 2.0 released by thedaemon on Thursday May 07, 2015 @12:09PM (#9506092)
I made the mistake of having the same hotkey once. I can verify the existence of said singularity.
Re:Tmux 2.0 released by smw on Thursday May 07, 2015 @03:16PM (#9507545)
Using ` as my bind (no modifier) has been the best thing that's ever happened to my productivity in tmux.
Re:Tmux 2.0 released by jwhitlark on Thursday May 07, 2015 @05:46PM (#9508532)
I do the same, and also set up many ` commands to work the same way in emacs.
Re:Tmux 2.0 released by rylee on Thursday May 07, 2015 @12:16PM (#9506157)
Consider using <C-Space>. I recently switched and it's made a world of difference to my speed.
Re:Tmux 2.0 released by mifix on Friday May 08, 2015 @03:11AM (#9510367)
Even faster, I set my prefix to just Caps-Lock. See https://github.com/mifix/dotfiles/blob/master/tmux.conf#L5
Re:Tmux 2.0 released by olalonde on Thursday May 07, 2015 @12:59PM (#9506516)
Amen. This, plus remapping Caps Lock to Ctrl on my Macbook Air was a life changer :)
Re:Tmux 2.0 released by msutherl on Thursday May 07, 2015 @04:21PM (#9507996)
FWIW, I spent some time deciding what to use years ago and decided on <C-j>. No complaints, and <C-s> feels awkward to me trying it now.
Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @11:28AM (#9505747)
I do. It's closer to the prefix/leader I was used to when using screen (<C-a>), and I find it easier to type.
Re:Tmux 2.0 released by aclissold on Thursday May 07, 2015 @11:55AM (#9505961)
Ahhhh. Maybe I'll switch from <C-a> to <C-s>, I still miss using <C-a> in Vim to increment integers!
Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @11:56AM (#9505968)
Exactly! And don't forget about <C-a> to move your cursor to the start-of-line in your terminal.
Re:Tmux 2.0 released by JoshTriplett on Thursday May 07, 2015 @11:30AM (#9505770)
Why not use C-a?
Re:Tmux 2.0 released by St-Clock on Thursday May 07, 2015 @11:41AM (#9505849)
I also use C-s on my local machine because:

1. I can still use C-a with readline (go to first character)

2. If I ssh and then use screen, I can use C-a to navigate my remote screen and C-s to navigate my local tmux.

3. C-s is closer to C-a then other letters on my keyboard.

Re:Tmux 2.0 released by e3b0c on Thursday May 07, 2015 @10:59PM (#9509763)
C-a still works with readline. You just need to C-a first to 'escape' tmux and then C-a again. Actually just hold ctrl and hit 'a' twice.

C-s will suspend the terminal on some platforms. (Which can be resumed by C-q.)

Re:Tmux 2.0 released by maw on Thursday May 07, 2015 @01:07PM (#9506594)
Because C-a already does something useful.
Re:Tmux 2.0 released by GrandTheftR on Thursday May 07, 2015 @11:35AM (#9505800)
I assume ctrl-s is easier to press than ctrl-a, I have trouble with ctrl-a on Mac with reconfigured CapsLock, and my bind key is ctrl-space.
Re:Tmux 2.0 released by Lio on Friday May 08, 2015 @03:42AM (#9510431)
That's why I remap the right alt key on mac (laptops) to ctrl. Having left right balanced ctrl keys is much more important for my workflow.
Re:Tmux 2.0 released by jbnicolai on Thursday May 07, 2015 @11:55AM (#9505959)
For a while I ran a setup where I did all of my work in a local tmux session, but part of this work involved SSH-ing and attaching to a screen session.

When using both, especially nested, I found it beneficial to have a different leader for each.

I also use <^-a> to go to the start of the line, so I'd miss that.

Re:Tmux 2.0 released by eddiezane on Thursday May 07, 2015 @12:18PM (#9506173)
I use `bind a send-prefix` and do a `<^-a> a` to make up for the bind :)
Re:Tmux 2.0 released by ghshephard on Thursday May 07, 2015 @12:36PM (#9506333)
Ctl+s is particularly nice if you've remapped CapsLock to Ctl.
Re:Tmux 2.0 released by klinquist on Thursday May 07, 2015 @06:58PM (#9508964)
Love your shell prompt. Mind posting your .zshrc/.bashrc?
Re:Tmux 2.0 released by klinquist on Thursday May 07, 2015 @07:07PM (#9509009)
Nevermind, looks like you are using powerline, found it, got it. :)