News for hackers. Stuff that matters.
Re:Benefits of using tmux – streamlining your development en... by nextos on Tuesday November 08, 2016 @03:30PM (#12903652)
Does anyone run tmux with a tiling window manager for local development?

If so, what are the advantages? I know automating sessions is one of them, as explained in the article.

I am more interested in hearing about interactions with the terminal. You already get good mouse-less window management with something like i3 or xmonad.

How about copy & paste? I use urxvt plugin for this, but I often find myself using the mouse to select and middle-click. Is tmux better?

Re:Benefits of using tmux – streamlining your development en... by julian_1 on Tuesday November 08, 2016 @04:41PM (#12904202)
I use screen (like tmux) and xmonad.

The tiling window-manager is used for longer running GUI apps - webbrowser, pdf/email viewer, CAD etc and for apps that I don't context switch as quickly. Also for handling the dual monitor setup.

I use screen for managing a consistent cli environment - that could be anywhere - on my dev machine, or sshd to a dev container or cloud box. I also tend to context switch screen environments much more quickly - eg. between edit (vim), compile and run turnaround.

Re:Benefits of using tmux – streamlining your development en... by pfranz on Tuesday November 08, 2016 @04:04PM (#12903927)
Similar to that, I've seen a lot of blog posts about Tmux and Vim, but I've been itching to see one where they talk about day-to-day. When do they use vim-split versus tmux pane, vim buffers versus tmux windows? I use both, but aren't very systematic...there's a bit of cognitive load when remembering which I'm using and using the different commands to navigate. You can't do diffs with panes and it's nice to use vim buffers instead of tmux windows when editing a series of files.

I imagine using a tiling window manager with tmux you'd have a similar issue. Sshing into a box you can launch tmux and have windows and splits inside, but you couldn't use your WM.

Re:Benefits of using tmux – streamlining your development en... by kornish on Tuesday November 08, 2016 @04:23PM (#12904063)
What I do, and would recommend, is spin up vim or emacs as a daemon, then connect to it as a client in one or more tmux windows.

That way, you can yank/put easily using the usual shortcuts from any tmux window to any tmux window. Then, it's usually easiest to only use intra-process pane splitting (keeping it all in vim or emacs) unless you need to do something that doesn't follow a perfect division, like:

top half vim / bottom left vim / bottom right trailing logfile

or something.

More than happy to write a blog post, if you're interested.

Re:Benefits of using tmux – streamlining your development en... by nilkn on Tuesday November 08, 2016 @04:41PM (#12904204)
I already use tmux and vim regularly but I'd definitely be interested in a blog post on this technique.
Re:Benefits of using tmux – streamlining your development en... by pfranz on Tuesday November 08, 2016 @05:48PM (#12904644)
Interesting to run it as a daemon and connect. I'd be curious to see how you set it up and use it in practice. Whenever I use vim splits I'm almost always diffing left and right. So, nothing fancy.
Re:Benefits of using tmux – streamlining your development en... by kornish on Tuesday November 08, 2016 @06:08PM (#12904767)
Definitely. If you shoot me an email ([email protected]) I'll let you know when the post is up. As a disclaimer, I use emacs with evil mode, not vim proper, so the command is just

  emacs --daemon=myproject
Then it's just

  emacsclient -nw -s myproject ./directoryhere
to connect, and the first part of that can be aliased away. Not 100% sure that vim has a good daemon/client mode, but I seem to recall something existing along those lines. It can be extremely useful to have multiple collections of editor panes set up, each in a different part of the codebase, and the ability to switch back and forth quickly with tmux - really helps for debugging and keeping organized.
Re:Benefits of using tmux – streamlining your development en... by greenshackle2 on Tuesday November 08, 2016 @04:23PM (#12904066)
I use a tiling WM with tmux and vim. I have three levels of windows/tabs. It's probably not optimal but I've gotten used to it.

I basically always run all my terminals in a single tmux'd window, and run a single instance of vim. I use vim windows when I edit multiple files at a time.

Re:Benefits of using tmux – streamlining your development en... by trungaczne on Wednesday November 09, 2016 @09:55AM (#12910675)
I used to use i3 and tmux for a time.

Advantage (of using tmux on top of i3):

When you spin up a new window with i3, it doesn't retain the previous's current working directory. There are some hacks to make it kind of work, none of which work nicely. With tmux it just works.

tmux has synchronized panes. It allows you to send same keystrokes to multiple terminals at once. This is useful for managing multiple host machines at once, i.e. ssh'ing into different machines at checking certain logs.

Disadvantages:

Double the amount of keybindings you need: one set for i3, one set for tmux. i3 allows you to active a mode where keystrokes are 'forwarded', so theoretically you can use the same keybindings for both, although it is very annoying if you forget to active this mode since you're now creating i3 windows instead of tmux panes and have to clean them up.

Re:Benefits of using tmux – streamlining your development en... by roblabla on Tuesday November 08, 2016 @05:51PM (#12904661)
I'm writing an i3/tmux integration similar to iTerm2's[0], but working at the WM layer, using i3 and urxvt.

The reason I'm doing this is that I'm often ssh'd into a box, and having to ssh into multiple terminal is a chore. I often create a spontaneous term that I close after a couple of minutes. Being able to have a dedicated ssh'd workspace where every split is ssh'd into the box would be a godsent.

This would also fix the mouse integration and various other things that annoy me with raw tmux.

[0]: https://www.youtube.com/watch?v=nGhfE9n1RLo

Re:Benefits of using tmux – streamlining your development en... by opk on Tuesday November 08, 2016 @06:08PM (#12904769)
This would be great if you get it working. I don't suppose you've got a link for what you've got so far in git or anything? I only make basic use of tmux because I'm more comfortable with i3 key bindings.
Re:Benefits of using tmux – streamlining your development en... by roblabla on Tuesday November 08, 2016 @06:16PM (#12904833)
Well, it's extremely rudimentary but I put everything on github :

https://github.com/roblabla/i3-tmux-integration/tree/in-prog...

I'm still stumbling in the dark trying to understand how everything works. Also, the code might be an abomination, my goal was mostly to get stuff working, refactoring will come later.

This project is at once a learning project for many things (tmux internals, Rust, IPC in general, i3 IPC) and a tool I've been really needing for a while, so progress is slow but steady (I mostly work on it in sleepless nights and week-ends).

Re:Benefits of using tmux – streamlining your development en... by curioussavage on Wednesday November 09, 2016 @05:53AM (#12909128)
This sounds cool. Especially for me since i have been using a chrome book with Linux. There is no cmd or windows key so I have to use alt for i3 but then have nothing for vim/tmux navigator.
Re:Benefits of using tmux – streamlining your development en... by 20after4 on Tuesday November 08, 2016 @07:24PM (#12905186)
That's really cool. I'm a linux user who lusts after all the cool stuff in iTerm2, so I appreciate what you are trying to do.
Re:Benefits of using tmux – streamlining your development en... by rcarmo on Tuesday November 08, 2016 @05:58PM (#12904703)
Since I can't use a tiling window manager everywhere, I do the next best thing: I have a set of key configs for most platforms that gives me (mostly) uniform control over windows, and then use the local terminal emulator with tmux inside.

I use Moom on the Mac with hotkeys that match the Windows left/right-side tiling, and a custom OpenBox config[1] that matches those too:

https://github.com/rcarmo/docker-templates/blob/master/deskt...

Then on the Mac I usually use the native Terminal (I keep trying to switch to iTerm, but most of the performance issues Terminal had have been ironed out by now), on Linux I usually use lxterminal, and on Windows I either use Cygwin's mintty or (more recently) wsltty to interact with Bash for Windows:

https://github.com/mintty/wsltty

(even though I'm a Microsoft employee, I strongly dislike the "feel" of the standard console and the way it handles both fonts and copy/paste, so I seldom use it at all)

I also tried various hacks to do raise on hover and suchlike, but I found that some things were best left "native" and get along OK with these bare mouseless window management hotkeys.

Incidentally, tmux has a growing following among my colleagues (there are a lot of Microsoft folk getting to grips with Bash and SSH these days, so when I tried to pass on some best practices, tmux was right at the top of the list)

Re:Benefits of using tmux – streamlining your development en... by 0xCMP on Tuesday November 08, 2016 @04:14PM (#12903988)
How do you deal with switching between projects though? I find my self switching between several projects as I'm working through something and suddenly something needs to be done in another project which is blocking someone. Wouldn't tmux + tmuxp (or similar) be more useful than just i3? Or do you have scripts for launching all those windows and putting them in the right place?
Re:Benefits of using tmux – streamlining your development en... by ianleeclark on Tuesday November 08, 2016 @03:38PM (#12903700)
I run i3 and tmux. The biggest reason I do this is that I'm much more used to tmux key bindings rather than i3. Moreover, I don't think I'd get any huge benefits by getting more used to i3 key bindings.

Edit for another reason: I use Tmux on my work laptop (OSX) and on my Desktop (FreeBSD + i3), so my key bindings are supported on essentially whatever machine I'm on.

Re:Benefits of using tmux – streamlining your development en... by ams6110 on Wednesday November 09, 2016 @12:53AM (#12906518)
I use a tiling window manager, and mainly use tmux to maintain ssh connections to other servers that I can connect to remotely.

So my main "jumphost" machine has a tmux session with multiple "tabs" logged in to other systems I manage. I can connect to this tmux session from my work desktop machine, from my laptop, or from home (via VPN). Makes it very easy to stop, go somewhere else, and pick up with everything the way I left it. I also don't worry about dropped remote ssh connections anymore (not uncommon at home because I often have to reset my cheap wireless router).

I don't do anything really advanced with tmux. One thing I'd like to know is a good way to deal with tmux within tmux, I have occasionally stumbled into that situation and then it's hard to get the "inner" tmux to do anything because the "outer" tmux intercepts all the key commands.

Re:Benefits of using tmux – streamlining your development en... by nilkn on Tuesday November 08, 2016 @03:46PM (#12903778)
I do. Part of it is just that I'm so used to it from using it remotely that I feel at home using it locally as well. But it's also very portable. For instance, I can use it in macOS or even on Windows using the Ubuntu bash subsystem. This makes it effectively a universal tiled window manager for me.
Re:Benefits of using tmux – streamlining your development en... by greenshackle2 on Tuesday November 08, 2016 @04:17PM (#12904013)
I use awesome wm with tmux and urxvt. Tmux has a nice copy mode, which has emacs and vi modes. By default it copies to tmux buffers, but you can set it up to copy to the system's clipboard:

https://coderwall.com/p/4b0d0a/how-to-copy-and-paste-with-tm...

It's rather idiosyncratic but I've gotten used to running all my terminals inside a single tmux window. I spend 95% of my time in either a terminal or Chrome so I basically only use awesome to switch between them, or put a browser and terminal side by side.

Re:Benefits of using tmux – streamlining your development en... by dllthomas on Tuesday November 08, 2016 @06:02PM (#12904732)
I use screen rather than tmux but the principal is the same.

I have set things up so that I maintain separate screen sessions per context, including separate shell histories (the single biggest win, by far), separate shell defaults, aliases, etc.

Re:Benefits of using tmux – streamlining your development en... by nicwest on Tuesday November 08, 2016 @04:06PM (#12903941)
I was a long time tmux user while on mac. Since I've swapped to arch and i3 I don't use tmux at all, and just use the WM. I basically live in terminals nowadays and I've not really missed tmux. The thing I really do miss is vim-tmux-navigator.

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

Re:Benefits of using tmux – streamlining your development en... by pyre on Tuesday November 08, 2016 @11:58PM (#12906174)
One thing that I like about tmux is using tools like tmuxinator to compose a project-related session where server processes are spun up in separate tmux windows. Do you have something equivalent to this with just i3 or is that just not your use-case?
Re:Benefits of using tmux – streamlining your development en... by minhajuddin on Tuesday November 08, 2016 @04:13PM (#12903982)
I use it with Xmonad, for me tmux's scripting and ability to detach and attach to sessions is a big win. It also allows me to run async tests by triggering a test from vim without blocking. And, the copy paste support is also very good.
Re:Benefits of using tmux – streamlining your development en... by devereaux on Tuesday November 08, 2016 @03:49PM (#12903794)
I do that, not in a real "tiling window manager" but something very close: openbox, set to show no titlebars, and using shortcuts to title the windows to precise positions. I have 3 position: most of my screen on the left, a small vertical slice on the right, a smaller chunk underneath. If I want a titlebar for some application, I have a shortcut that will give the window a titlebar, and then I can move it around with the mouse if I want to. So I get the best of both worlds.

Surprise - I don't run tmux. It is simpler to have several roxterm, in these position, with various tabs open. When I work remotely, I use screen on the remote host, but that's all.

To give you an idea of my shortcuts, in a real life scenario ; my caps lock is remapped to control or escape with xcape:

- esc: pop a new roxterm and from wherever I am, bring me to the terminal desktop

- f9: resize this roxterm to the left part of the screen

- esc: pop another roxterm, focus it

- ctrl-f9: resize it to the right vertical slice of the screen

- f4: switch to the browser desktop

- f12: put by browser in full screen, to check some reference without distraction

- f5: switch back to the terminals desktop

- alt-tab: switch to the roxterm that's currently on the right

- f12: make this roxterm full screen to do something without distraction for a while

- f12: demaximize and put back this roxterm where it was

- f9: now move this roxterm to the left, over the other one

- alt-tab: move to the other roxterm that was on the left

- ctrl-f9: put this roxterm in the vertical slice position on the right

- ctrl-space: make this roxterm sticky, showing on all desktop

- f4: move back to the internet desktop to check more documentation

- f9: resize the browser to be on the left part of the screen, so that I can see both the browser and the roxterm

- f5: move back to the terminal desktop. The space occupied by the browser will be replaced by the roxterm I left there, on the left

- alt-tab: move focus to this roxterm

- ctrl-t: open a new tab in this roxterm

- ctrl-v : paste some stuff from the internet browser

(etc..)

I have accomplished all that with about 20 keystrokes, from muscle memory. When I connect my extra wide screen, f10 and f11 have similar windows resizing function as f9 do on the laptop screen. f1 to f8 take me to desktop dedicated to some use or another (f7 is the windows desktop, with visual studio, f6 is the rstudio desktop, etc)

One think I positively hated until recently: copy and paste. Muscle memory means ctrl-shift-c in one application and ctrl-c in another didn't work. So in the terminal, I remapped the sigint signals to ctrl-x with stty. Hitting ctrl-x is just as convenient as ctrl-c and now I can copy paste as needed. ctrl-v to enter verbatim sequences is done with ctrl-q, just like in vim. so ctrl-c and ctrl-v work everywhere.

When I catch myself wanting to use the x copy paste buffer, the middle click is not so hard: on a thinkpad keyboard, it is right below the space key. But I just prefer ctrl-v. The luxury of having 2 independant copy-paste buffers is appreciable for some tasks however :)

Anyway, sorry for the long reply. I just don't have a lot of opportunities to talk about my setup. I am some kind of an optimization freak, I know it. But I don't want an interface to bother me. I have been using that for the last 3 or 4 years after giving up on OSX, and it has one great quality: I don't have to think about it. It just work the way I want. YMMV of course.

Re:Benefits of using tmux – streamlining your development en... by atweiden on Tuesday November 08, 2016 @04:22PM (#12904056)
I use Openbox with some keybindings I picked up from ArchBang a while back, documented here [1].

tmux really comes into its own when you combine it with Vim and FZF [2]. I was initially hesitant to try tmux, but once I themed my tmux.conf and nailed down the keybindings, it became indispensable to me. I now use tmux as a basic organizational tool, and I always have at least one tmux session running on my desktop.

I have Ctrl+A+S bound to split the tmux screen horizontally, and Ctrl+A+A to toggle maximizing the tmux pane. Shift-DownArrow opens up a new tmux window to the right of the current one. Shift-LeftArrow and Shift-RightArrow move left and right between the tmux windows. I wanted it to be reminiscent of URxvt tabs.

Another one of my favorite bindings works as follows: visually highlight a line in Vim, then hit <leader>tj, which sends the highlighted line of code to an open terminal in a split tmux window below. Very useful for REPLs. You can also open Vim in the lower split terminal and use the same keybinding to send text directly from one Vim instance to another. It uses vim-tbone [3] and some custom bindings from @junegunn.

[1] https://github.com/atweiden/dotfiles

[2] https://github.com/junegunn/fzf

[3] https://github.com/tpope/vim-tbone

Re:Benefits of using tmux – streamlining your development en... by devereaux on Tuesday November 08, 2016 @04:49PM (#12904257)
Very interesting. I love vim, and find the screen/vim mix a little unpleasant. A few years ago I looked at tmux and concluded I did't really need it because screen already did everything I needed.

On https://camo.githubusercontent.com/a3919061a8cf1a25c7150e3e0... I see you seem to be passing some info from vim to tmux right bottom bar, the utf8 the encoding. In vim, I usually show my offset in the file there.

Can you tell me more about that? The only thing I hate with gnu screen is the space wasted on the bottom bar, and the need to have commands in backticks otherwise

Would yo suggest some good resource to theme tmux? (I use the thinkpad dedicated previous and next button, right above the left and right arrow keys to move between tabs in all tabbed applications. A pleasure to use. With shift, then change me to the previous/next desktop. With control, they move the currently focused window to the previous or next desktop, and change focus to that desktop too)

Re:Benefits of using tmux – streamlining your development en... by atweiden on Tuesday November 08, 2016 @05:40PM (#12904604)
> I see you seem to be passing some info from vim to tmux right bottom bar, the utf8 the encoding. In vim, I usually show my offset in the file there.

The bottom bar is rendered by Vim with lightline [1]. The top bar is my tmux statusline, which I created by lightly customizing the output of tmuxline.vim [2].

I made my tmux.conf by customizing what I found on github, in particular @junegunn's dotfiles [3].

[1] https://github.com/itchyny/lightline.vim

[2] https://github.com/edkolev/tmuxline.vim

[3] https://github.com/junegunn/dotfiles

Re:Benefits of using tmux – streamlining your development en... by nextos on Tuesday November 08, 2016 @04:07PM (#12903949)
Thanks, this is very interesting.

I agree one of the major pain points of X11 systems, terminals, etc is the clipboard. So many different concepts and shortcuts across programs.

I use xmonad, urxvt or xterm, emacs-nox and vimperator. I'm trying to make all them consistent. Perhaps the last thing to polish in my setup.

Re:Benefits of using tmux – streamlining your development en... by ramblenode on Tuesday November 08, 2016 @05:31PM (#12904544)
Not ideal, but the best solution I've found so far for moving text between the command line and other applications in urxvt is setting Bash to vi mode and then using visual mode for yanking/putting. I have Vim as my $EDITOR, which is opened when entering visual mode (I believe opening the editor is default Bash behavior). Vim is set to use the system clipboard ("set clipboard=unnamedplus" in the .vimrc) so from there I can bus text to/from other applications.

Dealing with stdout/err is another beast...

Re:Benefits of using tmux – streamlining your development en... by devereaux on Tuesday November 08, 2016 @04:16PM (#12904006)
/bin/stty start "" stop "" intr ^x

add to .inputrc:

"\C-q": quoted-insert

Then remap copy to ctrl-c, and paste to ctrl-v, and ctrl-x will work like your old ctrl-c, while ctrl-q will work like your old ctrl-v. remapping is easy with roxterm. I suppose xterm and urxvt can do the same.

If you like to remove part of words in bash, the following can be helpful too:

"\C-s": backward-kill-word

"\C-g": kill-word

"\C-w": unix-word-rubout

Kill word vs word-rubout is a matter of taste, and which separators are in your filenames.

Re:Benefits of using tmux – streamlining your development en... by klinquist on Wednesday November 09, 2016 @12:38AM (#12906405)
Hm... Seems like a good opportunity for an open-source Touch Bar + tmux config package :).
Re:Benefits of using tmux – streamlining your development en... by GrinningFool on Wednesday November 09, 2016 @01:11AM (#12906630)
I use awesome wm, tmux and vim. awesome gets the job done. I don't see differences enough in the others to make me go through the trouble of switching. I'm not super fond of the default keybindings but I know the ones I need - easy to re-bind but not worth it.

I use mostly the stock awesomewm taskbar/dock setup. I tried doing custom stuff there and it was doable ... but the "reload my wm and see if it fails to start even though syntax check passed" got old, and I gave up.

I'll usually have my desktop split two thirds terminal, with the remaining third split between browser[1] and slack. (Or all terminal, with the other stuff on additional monitor(s)). I don't usually have enough windows open to use more than one 'tag' or desktop, but when I find myself wandering afield in my browsing, I tends to shunt offtopic stuff off to another tag.

I use two tmux sessions , with one showing at any one time. I run them in Konsole - out of all the terminal emulators I've found, that's the one that can handle massive scroll rates without lagging.

The first tmux session is named 'pairing' and is where I do my day-to-day work. Anyone on my team who sshs in will auto-connect to that session. For a while I had it prompting me for approval via an awesome popup but that broke with the ugprade to more recent versions and wasn't useful enough to fix. I now just have a notification that displays on connect/disconnect.

Within each session, I have topical windows - usually per-project. A single vim and one or more shell panes. I have set up (neo)vim so that any time I "vi" in any pane of a tmux window, it opens in that window's vi session. A given window may have quite a number of shell panes depending on the environment. And for some testing cases, tmux's "synchronize-window" is invaluable.

In vim, I prefer splits to tabs and end up using lots of both. I'm slowly learning to get comfortable with buffers and will see how that changes things.

In the second named session ('private') I manage mail (mutt, but experimenting with more CLI-driven options like nmh), twitter (rainbowstream), irssi (via nested tmux on a cheap vps) and my project/notes/todo manager - which is another three-pane vim split, with shell functions that let me send stuff over there/read from there from anywhere.

I rely heavily on small helper scripts and lately a growing number of custom macros on my keyboard.

Some of the things I've read in the comments here have given me plenty more stuff to explore :)

Heh. Now that I write it up, I see that it's apparently really complex - but it's evolved over time and suits my work really well. I'm still ironing out the info/todo management tooling but it looks promising.

[1] If browsing text wasn't a horrible experience I'd do all of that in the shell too.

Edit: If folks are remotely interested, I can write up a blog post and publish some of my hacks.