TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Tmux – The Essentials (2019)

152 点作者 devonnull2 个月前

15 条评论

anyfoo2 个月前
I like tmux a lot, but like its predecessor &quot;screen&quot; I mostly use it for explicitly running long-lived jobs (i.e. for its detach feature), and for very special situations where I have elaborate tmux window configurations with dedicated stuff running in each window&#x2F;pane.<p>Note that I have been using text-only terminals since the 1980s, but I&#x27;ve adapted my tty usage over time.<p>The problem that tmux (or screen) brings are first and foremost:<p>* Smooth&#x2F;fast scrolling goes away. I can no longer give my trackpad a slight push to find myself tens or hundreds of lines in the scrollback history, and visually scan by slightly pushing my fingers back and forth. Instead I have to use the horrendous in-tmux scrollback using &quot;Ctrl-b [&quot;.<p>* My terminal app&#x27;s tabs and windows are not tmux&#x27;s tabs and windows. I cannot freely arrange them in space, snap them off with the mouse, easily push them to another desktop, and so on. I have to start a multiple tmux clients and do awkward keyboard interactions with them for any of the same.<p>* tmux&#x27;s terminal emulation and my terminal emulator&#x27;s terminal emulation (heh) are not congruent. As a result, programs cannot make full use of my actual terminal&#x27;s capabilities. For example selecting, copying, and pasting text sometimes behave weirdly, and there are other annoyances.<p>What I&#x27;d <i>really</i> like to have instead is terminal session management at a higher level, i.e. involving my actual graphical terminal app itself. Attaching to a running session would mean restoring the terminal app&#x27;s windows and tabs, and the entire scrollback history within (potentially with some lazy loading).<p>tmux could likely be a major part of that, by providing the option of replacing its tty-facing frontend with a binary protocol that the graphical terminal app talks to, while keeping the backend (i.e. the part that provides the tty to anything running inside it) the same as it is today.<p>As it is, the downsides of using tmux all the time are too high.
评论 #43263197 未加载
评论 #43262480 未加载
评论 #43262349 未加载
评论 #43261954 未加载
评论 #43263449 未加载
评论 #43272967 未加载
评论 #43263600 未加载
评论 #43265282 未加载
评论 #43264739 未加载
评论 #43262382 未加载
评论 #43261955 未加载
mdaniel2 个月前
I&#x27;ll toss my &quot;works on my machine&quot; hat in the ring with two things that I have found invaluable in combination with iTerm2&#x27;s tmux integration:<p>- env KUBECONFIG=$HOME&#x2F;.kube&#x2F;setup-1 tmux new -s setup1<p>- teamocil: <a href="https:&#x2F;&#x2F;github.com&#x2F;remi&#x2F;teamocil#readme">https:&#x2F;&#x2F;github.com&#x2F;remi&#x2F;teamocil#readme</a> (MIT)<p>The first one I use for circumstances where I want to investigate a lot of different things in a dedicated cluster, without the hassle of having $(kubectl --kubeconfig ...) or the risk of k() { kubectl --kubeconfig ... &quot;$@&quot;; } and losing track of what context I&#x27;m in[1]. Because, with iTerm2&#x27;s integration command-n or command-t opens a new window or tab but with retaining the credential scoping. If I need to change scopes, I can just detach from the tmux session, attach to a different one, confident that I don&#x27;t have any variables to unset<p>The second I use in &quot;standard&quot; setups where I want to view the same configuration every day (say: web, api, database pods). Having teamocil allows me to either have those same commands laid out in the same pattern as yesterday, or I&#x27;ve also had pretty good luck just generating the yaml files because their syntax is simple enough<p>1: related to that, if you haven&#x27;t seen it, iTerm2 offers the ability to set the RGB of a tab via OSC: <a href="https:&#x2F;&#x2F;iterm2.com&#x2F;documentation-escape-codes.html#:~:text=tab%20chrome%20background-,color,-To%20set%20the" rel="nofollow">https:&#x2F;&#x2F;iterm2.com&#x2F;documentation-escape-codes.html#:~:text=t...</a>
评论 #43263115 未加载
Tsiklon2 个月前
Personally I find tmux’s default split keys to be a bit obtuse, personally I like to use hyphen and pipe for horizontal and vertical splits.<p>Likewise i enable vim keybindings, mouse mode, and if you use a Mac and iTerm selecting text will automatically drop it into your clipboard ready to paste.<p>I tend to make use of the following command - which will output the last 100000 lines of the current pane to a text file local to you; it’s useful for documenting screwups, maintenance work, and of course making notes on what you’ve done for future reference<p>&gt; bind-key P command-prompt -p &#x27;save history to filename:&#x27; -I &#x27;~&#x2F;tmux.history&#x27; &#x27;capture-pane -S -100000 ; save-buffer %1 ; delete-buffer&#x27;
pjs_2 个月前
Fun fact the main WSGI server for prod AWS console has been running out of a detached tmux process since 2018. We are just really careful not to press Ctrl-D
YouWhy2 个月前
My only non-truvial tip about tmux is that the only thing that one needs to do is to look for help: Ctrl+B then &#x27;?&#x27;, and then figure the rest out.<p>When I learnt tmux, I had to access multiple VMs which were de-facto ephemeral, which meant customization was not an option anyway. I kind of learnt to like the defaults as they are.
评论 #43267065 未加载
remram2 个月前
I tried to move to tmux, mostly because the Red hat servers at work don&#x27;t have screen, but I found out I really really prefer screen. The whole server&#x2F;session&#x2F;window&#x2F;pane thing is overly complicated and somehow still less capable than screen&#x27;s session&#x2F;pane&#x2F;window.<p>It&#x27;s a tiny bit more scriptable, but it&#x27;s not like a real API either.
评论 #43347214 未加载
评论 #43264686 未加载
评论 #43263532 未加载
评论 #43263252 未加载
lproven2 个月前
There are not so many console-mode windowing terminal multiplexors.<p>I am aware of tmux, dvtm, zellij, and GNU screen. That&#x27;s it: just 4.<p>Has anyone written a comparison of them? I would be genuinely interested. I personally favour ease of use over features.
评论 #43265334 未加载
评论 #43281778 未加载
评论 #43265268 未加载
lemonwaterlime2 个月前
I&#x27;m a fan of &quot;How to configure tmux from scratch&quot; [1]<p>[1]: <a href="https:&#x2F;&#x2F;ianthehenry.com&#x2F;posts&#x2F;how-to-configure-tmux&#x2F;" rel="nofollow">https:&#x2F;&#x2F;ianthehenry.com&#x2F;posts&#x2F;how-to-configure-tmux&#x2F;</a>
zvr2 个月前
Can anyone provide some information on the differences between tmux and screen? Are there significant features missing from one or the other? The more &quot;objective&quot; (or unbiased) the better. As an analogy, I know of some features available in neovim not available on vim; they are not important for me, so I continue to use vim. On the other hand, the vim features not available in vi made me switch.<p>I use screen, but whatever I have read till now on comparison seems to point more to personal preferences.
评论 #43264242 未加载
评论 #43265857 未加载
评论 #43264280 未加载
评论 #43264595 未加载
lynx972 个月前
There are three tmux customisations that I love and use all day:<p>1. Set the prefix key to C-Space. Much easier to type then any letter, and (in my case) only collides with Emacs set-mark. Its easy to remember and just type C-Space C-Space in that case.<p>2. Set IC (insert key) as prefix2. If you have a full-size keyboard, you can now scroll up by pressing insert (on the block of 6) and pageup. Easy to type.<p>3. Using sessions for ssh hosts. Add ControlPersist and&#x2F;or AddKeysToAgent to ~&#x2F;.config&#x2F;ssh and bind the following to some key. Pressing that key will prompt for a hostname, and create a new session named after that hostname. The default-command will make it such that Prefix c will open a new window which is already logged in on that host. Its not the same as running a remote tmux, as your windows&#x2F;session will not persist on the remote host, but it avoids nested tmux. I use it all the time during a typical day...<p>command-prompt -p &quot;Secure Shell ([user@]host):&quot; { new-session -A -s &quot;%1&quot; &quot;ssh %1&quot; ; set-option default-command &quot;ssh %1&quot; }
eu2 个月前
it&#x27;s missing changing Ctrl+B to Ctrl+A:<p><pre><code> # ~&#x2F;.tmux.conf set-option -g prefix C-a</code></pre>
评论 #43261865 未加载
评论 #43262593 未加载
评论 #43261854 未加载
评论 #43262170 未加载
g-b-r2 个月前
Since no one said it yet, in case you don&#x27;t already know tmux and you find it complex, zellij is a lot easier to learn
评论 #43264193 未加载
azaras2 个月前
I use byobu, a Tmux wrapper, as my primary terminal.<p>I changed the Keybindings for splitting and moving around terminals to be as in Emacs, and I am very happy.
alyandon2 个月前
I&#x27;ve slowly been converting from screen to tmux. However, muscle memory is really hard to overcome so I&#x27;ve come up with this:<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;alyandon&#x2F;b19e2634fac6505bb5bd0e0c99d856b0" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;alyandon&#x2F;b19e2634fac6505bb5bd0e0c99d...</a><p>Yes - I&#x27;m a terrible person.
avinassh2 个月前
Is there any introduction post on why one should use tmux OR what one is missing by not using them?
评论 #43263612 未加载
评论 #43267841 未加载