TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Using tmux properly

442 pointsby cmmn_nighthawkover 8 years ago

32 comments

rnhmjojover 8 years ago
Yesterday I was helping a friend setting a box with no graphical session: I fired up tmux in the linux virtual terminal and then proceeded to realize without my tmux.conf I couldn't do a thing because I have always been using entirely different keybindings from the default. This is the problem with too much customization. Learning to use the default configuration may be difficult but it's probably worth the effort, for vim it has definitely been in my experience.
评论 #13569222 未加载
评论 #13569129 未加载
评论 #13569302 未加载
评论 #13571223 未加载
评论 #13569214 未加载
评论 #13569050 未加载
评论 #13569548 未加载
评论 #13571694 未加载
评论 #13570139 未加载
评论 #13569505 未加载
评论 #13588275 未加载
评论 #13571936 未加载
评论 #13569630 未加载
评论 #13569992 未加载
git-pullover 8 years ago
I am author of <i>The Tao of tmux</i>, a book I just finished a few weeks ago. You can read it publicly at <a href="https:&#x2F;&#x2F;leanpub.com&#x2F;the-tao-of-tmux&#x2F;read" rel="nofollow">https:&#x2F;&#x2F;leanpub.com&#x2F;the-tao-of-tmux&#x2F;read</a>.<p>One of the things I stress in my book is that there is no &quot;correct&quot; way to use tmux. The approach I take to teaching tmux is separating it into its objects: The server, sessions, windows and panes. Then where they stand in relation to one another, how configurations work, and then leave some examples of usage available to the user so they can pick out work flows they may like.<p>I&#x27;m sort of against the approach of just throwing a config &#x2F; toolkit at someone a la oh-my-zsh and spf13-vim (even though I think they&#x27;re ok after you&#x27;ve learned to customize yourself). The gift of allowing someone to wrap their brain around something will let the rest come to them.
评论 #13571677 未加载
CaptSpifyover 8 years ago
I basically use tmux as my window manager. I only typically open two programs: a browser, and a terminal. Both are always in full-screen mode.<p>It makes things nice and simple. No matter if I&#x27;m working on a laptop or a desktop, all my terminal windows end up in the same place and have the same settings. It&#x27;s great!
评论 #13568621 未加载
评论 #13569375 未加载
评论 #13569806 未加载
评论 #13571955 未加载
KaiserProover 8 years ago
So this may mark me out as different, but apart from persistent remote connections, I&#x27;ve never really felt the need for screen&#x2F;tmux.<p>I&#x27;ve been trying to figure out what the fuss is about, and I still really don&#x27;t understand (apart from persistence and screen sharing.)<p>When I want multiple terminals, I just fire up another terminal window and hey presto, jobs a goodun. I have a fairly high res screen and small fonts, so I can fit many terminals on one screen. If I run out, I hop over to a new virtual screen.<p>Perhaps this is a by product of working in linux&#x2F;unix so long? I can imagine that if I was forced to use putty, where connection setup is costly and screen space scarce, I&#x27;d want tmux to make things quicker.<p>What am I missing?
评论 #13569597 未加载
评论 #13571032 未加载
评论 #13569895 未加载
评论 #13571950 未加载
评论 #13569594 未加载
3JPLWover 8 years ago
I use tmux constantly but I barely know three tmux commands. Get all the benefit with none of the cognitive overhead with `tmux -CC` in a supported terminal (like iTerm). It allows the GUI program to take charge of the windowing and paneling in its own native way. It&#x27;s lovely.
williamdcltover 8 years ago
It still sounds like a very shallow (naive?) use of tmux to me, I&#x27;m in no way a real power user of tmux and I use a lot more feature than that.<p>You could talk about binds without prefix, sessions, customized status bar, pane swapping, bind keys to script launching, plugins, pane highlighting...<p>And the best feature of all for me: maximized pane toggle. I use that ALL the time.<p>I never could find all features I needed from an emulator (plus, I want a drop-down terminal), Tmux have them all and more and I&#x27;m not dependent of a specific emulator.
评论 #13569388 未加载
评论 #13569366 未加载
评论 #13569130 未加载
skratloover 8 years ago
Most people use tmux locally, because their terminal emulator doesn&#x27;t do what they need it to do, or the window manager doesn&#x27;t do it. Using tmux locally merely supplements the window manager. I stopped using tmux locally after switching to i3 (and I believe any other tiling &#x2F; proper wm would do). Now my only use case for tmux is on the server where I&#x27;m running weechat. When sysadmining, it&#x27;s eaiser for me launch few terminals in my window manager and ssh to the same server, then running tmux remotely. It&#x27;s simply a question of ergonomics, how many sets of keyboard shortcuts do you need to remember to handle a multiplex... eh, window manager running inside a window manager?
arca_voragoover 8 years ago
echo &quot;alias tmux=&#x27;screen&#x27;&quot; &gt;&gt; ~&#x2F;.bashrc &amp;&amp; source ~&#x2F;.bashrc<p>But in all seriousness, I do sometimes find myself using tmux, but I try hard not to fragment myself over tools too much, especially with screen finally having vert split, and tmux being BSD, this is one of those cases where I think screen while it has some quirks and may have a bit of a learning curve is worth the effort.<p>edit: Since I didn&#x27;t provide much value and my comment was a bit snarky, here is a truly useful tmux shortcuts and cheatsheet link:<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;mischapeters&#x2F;462c6f383bfd9b2f9eea3fb7e6e5b79d" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;mischapeters&#x2F;462c6f383bfd9b2f9eea3fb...</a>
Morantronover 8 years ago
You are not using tmux properly if you don&#x27;t have tmux-fingers ( <a href="https:&#x2F;&#x2F;github.com&#x2F;morantron&#x2F;tmux-fingers" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;morantron&#x2F;tmux-fingers</a> ) installed B)<p>&lt;&#x2F;shameless-plug&gt;
评论 #13572852 未加载
elpockoover 8 years ago
There is one thing I want from my terminal multiplexer: working scroll functionality with Shift+PgUp&#x2F;PgDn, even in split screens, just like in a plain console, without messing everything up. Is that possible?
评论 #13568569 未加载
评论 #13568650 未加载
评论 #13568930 未加载
评论 #13568601 未加载
评论 #13568598 未加载
mcbuilderover 8 years ago
I used to be an extensive user of tmux, basically I&#x27;d have a sprawling set of sessions, all backed up with the continuum and resurrection plugins. It allowed me to armory seemlessly work remote on my main dev box or through SSH. Of course the biggest pain was consolidating the X11 clipboard and tmux&#x27;s internal one.<p>Since I switched to Emacs though I&#x27;ve gradually peeled away the tmux layer. I still run without X11 version of Emacs so I can remote in, but Emacs itself does an equal or better job at pane management and session persistence, especially using daemon mode. ANSI term inside Emacs, something that has really improved in the past few years, has cinched the deal for me. Tmux had become bloat at this point for me.
评论 #13571199 未加载
Zaheerover 8 years ago
After experimenting with mosh, tmux, screen, etc I&#x27;ve finally found my ideal ssh setup. At work I do development on my Mac and run builds on a cloud desktop. My Setup:<p>1. Unison for file-sync (<a href="https:&#x2F;&#x2F;www.cis.upenn.edu&#x2F;~bcpierce&#x2F;unison&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.cis.upenn.edu&#x2F;~bcpierce&#x2F;unison&#x2F;</a>)<p>2. iTerm on Mac<p>3. AutoSSH for more durable SSH sessions (ex. close laptop &amp; reopen at home) - <a href="http:&#x2F;&#x2F;www.harding.motd.ca&#x2F;autossh&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.harding.motd.ca&#x2F;autossh&#x2F;</a><p>4. tmux -CC command to attach to tmux session with iTerm Tmux integration. This is the killer feature, it treats a tmux session as a native iTerm window. This means all of the &#x27;learning&#x27; you previously had to do with Tmux is nearly non-existent (copy &#x2F; paste, switching tabs, etc). My biggest annoyance with TMux was the copy &#x2F; paste special handling. Huge productivity loss.<p>All-together it looks something like this: Open iTerm. autossh -t myRemoteHost &quot;tmux -CC -A&quot;<p>Instantly have a _fairly_ durable terminal session on my remote desktop.
评论 #13618177 未加载
trengrjover 8 years ago
I&#x27;d argue that using a terminal multiplexer like tmux or screen on a production server (as this article implied) often means you are doing things wrong.<p>It is better to set up a service (systemd or other) and configure it to start correctly rather than relying on a tmux session to manage long running processes. By going this route you get logging, auto restarting, starting on boot, monitoring etc for free.
评论 #13571098 未加载
adventistover 8 years ago
I love Tmux, I just can&#x27;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&#x27;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!
评论 #13572154 未加载
评论 #13570882 未加载
philippebackover 8 years ago
In my config, some better mouse support, 256color, history saving, config reload, and emoji-weather (temp + icon) in the status bar.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;philippeback&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;.tmux.conf" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;philippeback&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;.tmux.c...</a><p>Emoji-weather is to be taken from <a href="https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;emoji-weather" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;emoji-weather</a><p>Got this from Justin Campbell on LiveCodingTV. He has pretty good dotfiles <a href="https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;.dotfiles" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;.dotfiles</a><p>His Vim one pretty much takes the cake: <a href="https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;.dotfiles&#x2F;blob&#x2F;master&#x2F;.vimrc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;.dotfiles&#x2F;blob&#x2F;master&#x2F;.vim...</a><p>and this tmux-pomodoro is sweet. <a href="https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;tmux-pomodoro" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;justincampbell&#x2F;tmux-pomodoro</a><p>definitely more stuff than in mine <a href="https:&#x2F;&#x2F;github.com&#x2F;philippeback&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;.vimrc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;philippeback&#x2F;dotfiles&#x2F;blob&#x2F;master&#x2F;.vimrc</a>
babygetoboyover 8 years ago
The big problem I always have with tmux is that is messes up all of the colors in my Vim.
评论 #13568983 未加载
评论 #13569229 未加载
评论 #13570064 未加载
评论 #13569000 未加载
blfrover 8 years ago
<i>I use ... Screen on production servers. ... Screen has the lightest footprint</i><p>dtach, which is what I use on production servers even though it usually doesn&#x27;t come standard, probably has the lightest footprint if you just want to return to some screen later. It doesn&#x27;t maintain history, however, the screen is redrawn, if possible, on reattach.<p>Otherwise, yes. Both tmux and the book are great (if you don&#x27;t mind getting drawn into wasting time on customizing the status bar and such).
jphover 8 years ago
Tmux dot files with annotations-- may be helpful for people here.<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13570010" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13570010</a><p>Direct link to the tmux dot files repo on GitHub:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;SixArm&#x2F;sixarm_tmux_dotfiles" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;SixArm&#x2F;sixarm_tmux_dotfiles</a>
rhinoceraptorover 8 years ago
I have my tmux&#x2F;vim set up so that C-(h,j,k,l) navigates vim splits and tmux panes seamlessly. The only downside was that I had to rebind C-l to C-o to clear my shell. But it makes it a lot more productive when using multiple shell panes along with my vim session in one terminal window.
dllthomasover 8 years ago
A big thing I&#x27;ve done is use my multiplexer segregate contexts. When I spin up screen (tmux would work the same, just never switched) I set an environment variable noting the particular context I&#x27;m working in, and I adjust my PATH, HISTFILE, and more based on this variable.
评论 #13568552 未加载
owenwwover 8 years ago
Great read - prompted me to actually learn tmux, has been worth it! Also thanks for the link to the book, I ended up buying <a href="https:&#x2F;&#x2F;pragprog.com&#x2F;book&#x2F;bhtmux2&#x2F;tmux-2" rel="nofollow">https:&#x2F;&#x2F;pragprog.com&#x2F;book&#x2F;bhtmux2&#x2F;tmux-2</a>
autoreleasepoolover 8 years ago
What&#x27;s the advantage of tmux over something like terminator with pane splitting?
评论 #13569634 未加载
评论 #13568755 未加载
评论 #13569068 未加载
oconnor663over 8 years ago
My favorite tip: add bindings with the control key. So if you use &quot;Ctrl-b n&quot; to go to the next pane, add a binding for &quot;Ctrl-b Ctrl-n&quot;. It&#x27;s easier to keep the Ctrl key pressed than to lift it.
评论 #13569381 未加载
gbrown_over 8 years ago
So &quot;properly&quot; means customizing to user preference?
评论 #13568636 未加载
pkayeover 8 years ago
Does mouse copy and paste work correctly with tmux? I find that it selects spans across multiple panes. Is there a way to fix this or Windows or Linux?
评论 #13569044 未加载
评论 #13572889 未加载
评论 #13569063 未加载
评论 #13574085 未加载
评论 #13569310 未加载
ausjkeover 8 years ago
I used the default all the time and it worked fine for me.<p>by the way what is PREFIX meaning? ctrl-b?
评论 #13570603 未加载
vlunkrover 8 years ago
My biggest question is why are they still using screen when sshing?
drieddustover 8 years ago
bind | split-window -h bind - split-window -v<p>Binding vertical bar to horizontal and visa versa seems weird. Shouldn&#x27;t it be otherway around.
arc_of_descentover 8 years ago
Wow! PREFIX t displays the time!
gcb0over 8 years ago
&gt; uses gnu screen on all servers.<p>&gt; uses tmux on dev box<p>&gt; advocates tmux but do not mention a single feature not on gnu screen.<p>why on earth would someone be that impractical?! just get a single gnu screenrc file that does all that and call it a day on every single environment you work on.
vegabookover 8 years ago
Honestly, tmux is not hard to use. It has some contorted key bindings, sure, but its benefits are so immediately huge that the motivation to learn its quirks is huge too. And, unlike say, vim, it only has 3 things you really need to know: panes, windows, detach. Most people who use tmux, even casually, will inevitably be using it &#x27;properly&#x27;, within a week, and fluidly within a month. So this blog post is quite redundant.
zumpover 8 years ago
can someone eli5 how to copy to the clipboard using this thing without spending 100 calories in my upper torso