4 款很酷的终端复用器
终端 tmux
![](/data/attachment/album/201907/04/125200klg0curz7oczf0tt.jpg)


Fedora 系统对很多用户来说都很舒适。它有一个令人惊叹的桌面，可以轻松地完成日常任务。而在这光鲜的表面之下是由 Linux 系统提供的支持，而终端是高级用户使用这些底层能力的最简单方法。默认的终端简单且功能有限。但是，*终端复用器*能让你的终端变得非常强大。本文展示了一些流行的终端多路复用器以及如何安装它们。


为什么要用它？嗯，首先，它可以让你注销你的系统，而同时*让你的终端会话不受干扰*。退出你的控制台，这样安全，在其他地方旅行时通过远程登录 SSH 继续之前的操作是非常有用的。这里有一些工具可以看下。


最古老和最知名的终端多路复用器之一是 `screen`。但是，由于其代码不再维护，本文将重点介绍最近的应用。 （“最近的”是相对而言的，其中一些已存在多年！）


### Tmux


`tmux` 是 `screen` 最广泛使用的替代品之一。它有高度可配置的接口。你可以根据需要对 `tmux` 进行编程以启动特定类型的会话。在前面发表的这篇文章中你会发现更多关于 tmux 的信息：


* [使用 tmux 实现更强大的终端](https://fedoramagazine.org/use-tmux-more-powerful-terminal/)


已经是 `tmux` 用户？你可能会喜欢[这篇使你的 tmux 会话更有效的文章](https://fedoramagazine.org/4-tips-better-tmux-sessions/)。


要安装 `tmux`，由于你可能已经在终端中，请带上 `sudo` 使用 `dnf`：



```
$ sudo dnf install tmux
```

要开始学习，请运行 `tmux` 命令。单窗格窗口以你的默认 shell 启动。tmux 使用*修饰键*来表示接下来会发出命令。默认情况下，此键为 `Ctrl+B`。如果输入 `Ctrl+B, C`，你将创建一个带有 shell 的新窗口。


提示：使用 `Ctrl+B, ?` 进入帮助模式，会列出你可以使用的所有键。为了简单起见，你先查看 `bind-key -T prefix` 开头的行。这些是你可以在修饰键之后立即使用的键，可以用来配置你的 `tmux` 会话。你可以按 `Ctrl+C` 退出帮助模式回 `tmux`。


要完全退出 `tmux`，请使用标准 `exit` 命令或 `Ctrl+D` 退出所有 shell。


### Dvtm


你可能最近在 Fedroa Magzine 上看到过一篇 [dwm，一个动态窗口管理器](https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/)的文章。像 `dwm` 一样，`dvtm` 用于平铺窗口管理，但是是用在终端中。它的设计坚持 UNIX 的“做好一件事”的理念，在这里是管理终端中的窗口。


安装 `dvtm` 也很简单。但是，如果你想要前面提到的注销功能，你还需要 `abduco` 包来处理 dvtm 的会话管理。



```
$ sudo dnf install dvtm abduco
```

`dvtm` 已经映射了许多管理终端窗口的按键。默认情况下，它使用 `Ctrl+G` 作为其修饰键。这个按键告诉 `dvtm` 接下来的字符将成为它应该处理的命令。例如， `Ctrl+G, C` 创建一个新窗口，`Ctrl+G, X` 将其关闭。


有关使用 `dvtm` 的更多信息，请查看 `dvtm` 的[主页](http://www.brain-dump.org/projects/dvtm/#why)，其中包含大量提示和入门信息。


### Byobu


虽然 `byobu` 本身并不是真正的多路复用器 —— 它封装了 `tmux` 甚至更老的 `screen` 来添加功能，但它也值得在这里一提。通过帮助菜单和窗口选项卡，以便更加容易地找到那些功能，`byobu` 使终端复用器更适合初学者。


当然它也可以在 Fedora 仓库中找到。要安装它，请使用以下命令：



```
$ sudo dnf install byobu
```

默认情况下，`byobu` 会在内部运行 `screen`，因此你可能希望运行 `byobu-tmux` 来封装 `tmux`。你可以使用 `F9` 键打开帮助菜单以获取更多信息，来帮助你入门。


### Mtm


`mtm` 是你可以找到的最小的复用器之一。事实上，它只有大约 1000 行代码！如果你处于受限的环境（例如旧硬件、最小容器等）中，你可能会发现它很有用。要开始使用，你需要安装一些包。



```
$ sudo dnf install git ncurses-devel make gcc
```

然后克隆 `mtm` 所在的仓库：



```
$ git clone https://github.com/deadpixi/mtm.git
```

进入 `mtm` 文件夹并构建程序：



```
$ make
```

你可能会收到一些警告，但完成后，你将会有一个非常小的 `mtm` 程序。使用以下命令运行它：



```
$ ./mtm
```

你可以在 [GitHub 页面](https://github.com/deadpixi/mtm)上找到该程序的所有文档。


这里只是一些终端复用器。你有想推荐的么？请在下面留下你的评论，享受在终端中创建窗口吧！




---


via: <https://fedoramagazine.org/4-cool-terminal-multiplexers/>


作者：[Paul W. Frields](https://fedoramagazine.org/author/pfrields/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
The Fedora OS is comfortable and easy for lots of users. It has a stunning desktop that makes it easy to get everyday tasks done. Under the hood is all the power of a Linux system, and the terminal is the easiest way for power users to harness it. By default terminals are simple and somewhat limited. However, a *terminal multiplexer* allows you to turn your terminal into an even more incredible powerhouse. This article shows off some popular terminal multiplexers and how to install them.

Why would you want to use one? Well, for one thing, it lets you logout of your system while *leaving your terminal session undisturbed*. It’s incredibly useful to logout of your console, secure it, travel somewhere else, then remotely login with SSH and continue where you left off. Here are some utilities to check out.

One of the oldest and most well-known terminal multiplexers is *screen.* However, because the code is no longer maintained, this article focuses on more recent apps. (“Recent” is relative — some of these have been around for years!)

## Tmux

The *tmux* utility is one of the most widely used replacements for *screen.* It has a highly configurable interface. You can program tmux to start up specific kinds of sessions based on your needs. You’ll find a lot more about tmux in this article published earlier:

Already a tmux user? You might like [this additional article on making your tmux sessions more effective](https://fedoramagazine.org/4-tips-better-tmux-sessions/).

To install tmux, use the *sudo* command along with *dnf*, since you’re probably in a terminal already:

$ sudo dnf install tmux

To start learning, run the *tmux* command. A single pane window starts with your default shell. Tmux uses a *modifier key* to signal that a command is coming next. This key is **Ctrl+B** by default. If you enter **Ctrl+B, C** you’ll create a new window with a shell in it.

Here’s a hint: Use **Ctrl+B, ?** to enter a help mode that lists all the keys you can use. To keep things simple, look for the lines starting with *bind-key -T prefix* at first. These are keys you can use right after the modifier key to configure your tmux session. You can hit **Ctrl+C** to exit the help mode back to tmux.

To completely exit tmux, use the standard *exit* command or *Ctrl+D* keystroke to exit all the shells.

## Dvtm

You might have recently seen the Magazine article on [dwm, a dynamic window manager](https://fedoramagazine.org/lets-try-dwm-dynamic-window-manger/). Like dwm, *dvtm* is for tiling window management — but in a terminal. It’s designed to adhere to the legacy UNIX philosophy of “do one thing well” — in this case managing windows in a terminal.

Installing dvtm is easy as well. However, if you want the logout functionality mentioned earlier, you’ll also need the *abduco* package which handles session management for dvtm.

$ sudo dnf install dvtm abduco

The dvtm utility has many keystrokes already mapped to allow you to manage windows in the terminal. By default, it uses **Ctrl+G** as its modifier key. This keystroke tells dvtm that the following character is going to be a command it should process. For instance, **Ctrl+G, C** creates a new window and **Ctrl+G, X** removes it.

For more information on using dvtm, check out the dvtm [home page](http://www.brain-dump.org/projects/dvtm/#why) which includes numerous tips and get-started information.

## Byobu

While *byobu* isn’t truly a multiplexer on its own — it wraps *tmux* or even the older *screen* to add functions — it’s worth covering here too. Byobu makes terminal multiplexers better for novices, by adding a help menu and window tabs that are slightly easier to navigate.

Of course it’s available in the Fedora repos as well. To install, use this command:

$ sudo dnf install byobu

By default the *byobu* command runs *screen* underneath, so you might want to run *byobu-tmux* to wrap *tmux* instead. You can then use the **F9** key to open up a help menu for more information to help you get started.

## Mtm

The *mtm* utility is one of the smallest multiplexers you’ll find. In fact, it’s only about 1000 lines of code! You might find it helpful if you’re in a limited environment such as old hardware, a minimal container, and so forth. To get started, you’ll need a couple packages.

$ sudo dnf install git ncurses-devel make gcc

Then clone the repository where mtm lives:

$ git clone https://github.com/deadpixi/mtm.git

Change directory into the *mtm* folder and build the program:

$ make

You might receive a few warnings, but when you’re done, you’ll have the very small *mtm* utility. Run it with this command:

$ ./mtm

You can find all the documentation for the utility [on its GitHub page](https://github.com/deadpixi/mtm).

These are just some of the terminal multiplexers out there. Got one you’d like to recommend? Leave a comment below with your tips and enjoy building windows in your terminal!

## murph

I’m pretty sure that screen is still actively maintained. It doesn’t need to be included, (That’s up to you) but no reason to say that it’s not being maintained. http://git.savannah.gnu.org/cgit/screen.git/log/

## dac.override

“By default terminals are simple and somewhat limited”

Not TermySequence

TermySequence is:

A server implementation written in cross-platform, multithreaded C++ with minimal dependencies.

A Qt-based client implementation with its own set of features, including a plugin system using an embedded Chrome V8 Javascript engine.

A terminal emulation system with a focus on connectivity, productivity, and collaboration.

Free software, licensed under GPLv2.

TermySequence is packaged for:

https://termysequence.io/

## Clément Verna

TermySequence looks really cool, would you be interested in writing an article about it for the Fedora Magazine ?

## dac.override

I am not such a write, but i can give you a run-down here and maybe someone else can write a nice article:

Someone once said: “By default terminals are simple and somewhat limited”.

Many of us spend significant time using terminal emulators. Yet A lot of us want it to be fast and light. Why skim on something as

important as a terminal emulator?

If youre familiar with terminal multiplexers then you probably know some of their limitations. Take for example nesting.

You open a terminal emulator locally, then execute a terminal multiplexer. Then you use ssh to connect to a remote machine and either

run another terminal multiplexer there or attach to an existing one. Now you have a terminal multiplexer running in another terminal multiplexer.

That is where things get confusing because your usual keyboard shortcuts only work for the local instance. You would use different shortcuts

to control the remote instance.

On top of that, sometimes you need to read or edit a remote file. Things would get even more complicated there because for example if it is a

pdf then you might for example use

and then run

on the remote. There are two considerations there: 1. you need a display

server on the remote, 2. youre running a remote instance of apvlv. Otherwise you might use fusermount and/or sshfs to mount the remote pdf

locally so that you can open it with your local apvlv instance. Eitherway, not ideal.

Enter TermySequence:

So why is there no solution for these issues? Why can’t we have all this integrated into a terminal emulator?

TermySequence is a rather heavy weight solution compared to say using a “simple” terminal emulator, ssh, fusermount, and a terminal multiplexer.

It integrates these features in a neat new way and hides some of the dirty details. It is basically a client and server model.

You can either just have a termy-server running on a remote headless system and connect to that with a local termy-qt client and/or have both

server and client. You connect from the client to server instances, locally and remote. When you close the client, your work done in terminals

running on the server instances is not lost and you can reattach later, just like terminal multiplexers. You can also connect from one server

instance to another, effectively chaining connections.

There is a file manager that can be used to open remote files with local applications seemingly transparently. You can do collaboration

easily by sharing termy-server instances. Either take ownership of your own terminals or allow remote input. You can attach avatars so that

people can “put a face on a terminal”.

TermyQT is a modern terminal emulator, so you get emoji, inline images, a plugin framework and a lot of other features. Too many to

address here.

## Sorin

… and there’s the article… lol…

## bachradsusi

My favorite multiplexer is a combination of

emacs-noxin daemon mode,emacslientand(ansi-term “/usr/bin/zsh”)## dac.override

Yes I agree, that is nice as well, together with tramp mode: https://www.emacswiki.org/emacs/TrampMode

## Luciano

I understand the need to multiplex terminal window…

But I don’t really understand what these programs provide in addition to the features of, say, Konsole. I can have tabs, split windows… I can send the same input to multiple subwindows.

What can these provide that I cannot already do with Konsole?

Unless the terminal session is in a non graphical environment, of course, but that’s not common for me.

## Paul W. Frields

@Luciano: That’s exactly what these multiplexers are for. Having a multiplexed session available via either GUI or console is very useful. There are also plenty of situations where, say, passing graphical information over an SSH tunnel is unwanted. Glad you don’t need it, but many people do. 🙂

## epii

Check out terminator, available in Debina, Ubuntu, Linux Mint, etc. Easy to setup, use and very configurable.

## far2fish

I use terminator as my preferred terminal in Fedora 29.

## Cata

PAC Manager is my favorite, is more a connection manager but is useful when you have many servers to take care.

## Thomas Stephen Lee

Hi,

A bug I ran into.

https://bugzilla.redhat.com/show_bug.cgi?id=1480460

Affects byobu