tmux

在 iTerm2 中使用 tmux

假如想象 提交于 2019-12-06 15:35:55
作为开发者,不断和服务器打交道,最烦躁的是,每次用 ssh 连接服务器时,总担心网络不稳定导致在服务器端执行耗时的任务会被中断。有时候服务器一边在执行命令,一边又想看看服务器内存、CPU 等运行情况,这时候不得不再打开一个终端执行 ssh 连接操作。 最近发现一个好工具:「tmux」,恰好能解决这些问题,今天分享出来。 首先说一说 tmux 的好处。 tmux 优点 分屏 在 Mac 上,iterm2 也是可以做到分屏,但如果结合 iterm2 与 ssh 的话,iterm2 分屏需要不断地 ssh ,导致的后果就是有多个用户连接,使用 who 命令查看登录用户数。 举个例子,如果是 iterm2 分屏三个,则用户连接数为:3 但,如果是用 tmux 的话,相同的目标,用户连接数为:1 attach attach 可以起到保护现场的作用,不至于因 ssh 超时或者异常退出,而丧失了工作环境。 我做了一个测试,先在 tmux 环境下 git clone 代码。 接着关闭 ssh 环境一段时间,然后我重新连接服务器,这时候发现工作环境保持状态,并且持续下载中: 其中原理我觉得可以这么理解:tmux 运行在远程主机上,充当中介的作用。本地终端应首先 ssh 到远程主机,然后运行一个 tmux 会话,在会话内的 shell 中运行任务。当本地切断 ssh 连接时,应当先结束 tmux 会话

tmux: how to adjust the tmux session's width to fit in the terminal panel?

烈酒焚心 提交于 2019-12-06 15:13:51
when I re-attach a tmux session, the width of the tmux window is still the previous width and padded with white dots: So my question is how to adjust the tmux width to fit in the terminal panel? The ideal setting would be the tmux session's width is auto-adjusted whenever re-attached. PS: I am using iterm2 on mac. EDIT: This is actually answered here: https://stackoverflow.com/a/19280187/1464263 Seems like you have another client attached to this session and it's screen width is half your screen width. If you detach that second session those dots should go away. tmux ls will show you all the

在 iTerm2 中使用 tmux

安稳与你 提交于 2019-12-06 15:13:28
作为开发者,不断和服务器打交道,最烦躁的是,每次用 ssh 连接服务器时,总担心网络不稳定导致在服务器端执行耗时的任务会被中断。有时候服务器一边在执行命令,一边又想看看服务器内存、CPU 等运行情况,这时候不得不再打开一个终端执行 ssh 连接操作。 最近发现一个好工具:「tmux」,恰好能解决这些问题,今天分享出来。 首先说一说 tmux 的好处。 tmux 优点 分屏 在 Mac 上,iterm2 也是可以做到分屏,但如果结合 iterm2 与 ssh 的话,iterm2 分屏需要不断地 ssh ,导致的后果就是有多个用户连接,使用 who 命令查看登录用户数。 举个例子,如果是 iterm2 分屏三个,则用户连接数为:3 但,如果是用 tmux 的话,相同的目标,用户连接数为:1 attach attach 可以起到保护现场的作用,不至于因 ssh 超时或者异常退出,而丧失了工作环境。 我做了一个测试,先在 tmux 环境下 git clone 代码。 接着关闭 ssh 环境一段时间,然后我重新连接服务器,这时候发现工作环境保持状态,并且持续下载中: 其中原理我觉得可以这么理解:tmux 运行在远程主机上,充当中介的作用。本地终端应首先 ssh 到远程主机,然后运行一个 tmux 会话,在会话内的 shell 中运行任务。当本地切断 ssh 连接时,应当先结束 tmux 会话

Convert current tmux session to configuration file

我与影子孤独终老i 提交于 2019-12-06 12:09:19
问题 I'm running a tmux session with 6 windows, about 14 panes in all. Is there a command way to save this session to a tmux configuration file? I'm not worried about running any of the programs, but hopefully I'll be able to keep the session name, window names, and pane folder locations. 回答1: tmux by default doesn't provide any way to save/restore sessions/clients. But there are 3rd party tools to achieve it. For example, I wrote retmux to do exactly what you are asking for. https://github.com

tmux: how to open file under cursor

无人久伴 提交于 2019-12-06 09:30:24
i am a vim user and got used to the gf command, which opens the file under the cursor. Now i wanted to ask, if there is something like that for tmux. I can navigate through a tmux-pane and it happens often that there is a file-path under the cursor. Now i like to have the possibility to open that file under the cursor with vim. A: in the current window B: in another window which includes and opened vim Maybe there is a possibility to run a sh-script in that navigation-mode when invoking a special key-combination? that would make it possible to write my own scripts like i got used to in vim

Make Alt + h switch to the left pane in Tmux

北战南征 提交于 2019-12-06 06:53:42
I'm trying to make Alt - h switch to the left pane in Tmux. This does not work: bind -n M-h select-pane -L Pressing Alt - h in cat generates the following output in my terminal: $ cat ^[h That is, it looks like Alt generates ^[ in my terminal. So, in my Tmux configuration, I have also tried this binding: bind -n ^[h select-pane -L I have made "^[" both a literal two character string (i.e., "^" + "[") as well as the special "^[" character you can access in Vim. Neither work. How to solve this problem? EDIT: I'm primarily using xfce4-terminal as my terminal emulator, but I've tried using gnome

tmux在busybox上的移植

左心房为你撑大大i 提交于 2019-12-06 03:43:09
作者:彭东林 邮箱:pengdonglin137@163.com 参考 https://gist.github.com/tessus/5e118d44261a6ab2f198 环境 Qemu-4.1 Linux-4.14 ARM64 aarch64-linux-gnu-gcc 8.3 概述   在进行嵌入式开始时,经常会用到串口,这样就可以使用串口来登录到板子上,但是如果通过一个串口实现多个终端的功能的话,对于我们的开发调试就会更加方便,而tmux就提供了这样的功能。   下面介绍tmux如何静态交叉编译,使其运行在arm开发板上。 软件版本 tmux-2.1 libevent:2.1.10 ncurses-6.1 正文 交叉编译tmux需要libevent和ncurses两个软件包。 下载和编译libevent 1、下载libevent: https://github.com/libevent/libevent/releases/download/release-2.1.10-stable/libevent-2.1.10-stable.tar.gz 2、解压和交叉编译,下面是编译脚本: 1 ./configure --prefix=`pwd` \ 2 --host=aarch64-linux-gnu \ 3 --disable-shared 4 5 make 6 make

How to disable keybinding in Tmux

会有一股神秘感。 提交于 2019-12-06 00:48:54
问题 Using Tmux and Vim is a pain sometimes. One of the collisions for me is Control-S . I use it in Vim for opening buffers in split, but when using Tmux, well... Tmux does something stupid with it, I can't figure out whats the purpose. But basically, when C-s is pressed in Tmux, screen freezes. And it unfreezes with C-q . I've no idea whats that good for, if anything. unbind C-s unbind C-q I tried to unbind C-s in tmux.conf, but it didn't work. How can I unbind it? Also I freed the binding from

怎样管理 linux / mac 的配置文件

痞子三分冷 提交于 2019-12-05 21:47:06
怎样管理 linux / mac 的配置文件 在 *nix 系统中,home 目录下一般有许多程序的配置文件( rc files ),它们可以更改程序运行时的行为。 如何管理并在多台机器上分享、同步这些配置文件也算是一个棘手的问题,当然解决方法也有不少 使用 git 直接管理 home 目录 使用 git 之类的版本控制工具把整个 home 目录保存下来,这其中 ignore 文件也有两种处理方式 一种是先 ignore 所有,然后排除需要的文件 示例: cat ~/.gitignore /* !/.gitignore !/.bashrc /some_dir/* !/some_dir/sub_dir/* # ... 另一种是 ignore 不需要的文件 示例: cat ~/.gitignore /Desktop /Documents # ... 利弊 利 : 简单,直观 弊 :home 目录会显得不干净,而且每次增加、删除文件都需要更改 .gitignore 文件。 使用 symbolic link 把配置文件集中到一个 home 的子目录,比如 ~/.dotfiles ,在 home 目录创建链接到这个 .dotfiles 目录的 symbolic link ,这样只需要把这个 .dotfiles 目录使用 git 管理就好了 但是会遇到几个问题 对待同名目录,单纯 link

Tmux 简介与使用

时光怂恿深爱的人放手 提交于 2019-12-05 19:27:46
Tmux 是一个用于在终端窗口中运行多个终端会话的工具,即终端复用软件(terminal multiplexer)。在 Tmux 中可以根据不同的工作任务创建不同的会话,每个会话又可以创建多个窗口来完成不同的工作,每个窗口又可以分割成很多小窗口。这些功能都是非常实用的。 Tmux 的多窗口和窗口分割并不是它吸引的我原因,对于这一点我可以有另外一个终端工具代替,即 Terminator。 使用 Tmux 最大的益处在于,远程 SSH 访问服务器进行工作时 。即使非正常掉线,它能保存当前工作状态,并保证当前任务继续运行。这一点对于远程 SSH 工作的人来说是非常重要的。远程 ssh 工作时,Tmux 的多会话、多窗口、多面板的益处才充分体现了出来。使用 Tmux 就不必开启多个标签连接多个 ssh 了,所有工作在一个 ssh 连接上就搞定了,也不必担心突然掉线后工作丢失。 与 Tmux 类似的软件还有 screen、dvtm、splitvt、byobu 等。 会话, 窗口, 窗格 根据 Tmux 的定义,在开启了 Tmux 服务器后,会首先创建一个会话,而这个会话则会首先创建一个窗口,其中仅包含一个窗格;也就是说,这里看到的所谓终端控制台应该称作 Tmux 的一个窗格,虽然其使用方法与终端控制台完全相同。 Tmux 使用 C/S 模型构建,主要包括以下单元模块: server 服务器