我如何设置tmux,使它启动与指定的窗口打开?


当前回答

有一个tmux插件。

查看tmux- resurrection

Restore tmux environment after system restart. Tmux is great, except when you have to restart the computer. You lose all the running programs, working directories, pane layouts etc. There are helpful management tools out there, but they require initial configuration and continuous updates as your workflow evolves or you start new projects. tmux-resurrect saves all the little details from your tmux environment so it can be completely restored after a system restart (or when you feel like it). No configuration is required. You should feel like you never quit tmux.

或tmux-continuum

特点: 持续节约tmux环境 当计算机/服务器打开时自动启动tmux tmux启动时自动恢复

其他回答

您可以编写一个小型shell脚本,用所需的程序启动tmux。我在一个称为dev-tmux的shell脚本中有以下内容。开发环境:

#!/bin/sh
tmux new-session -d 'vim'
tmux split-window -v 'ipython'
tmux split-window -h
tmux new-window 'mutt'
tmux -2 attach-session -d

所以每次我想启动我最喜欢的开发环境时,我都可以这样做

$ dev-tmux

这对我很有用。创建5个具有给定名称的窗口,并自动选择到主窗口。

new  -n home
neww -n emacs
neww -n puppet
neww -n haskell
neww -n ruby
selectw -t 1

这个脚本启动一个名为“e”的会话和三个窗口

#!/bin/sh 
tmux new-session -s e   -n etc -d 'cd /etc; bash -i'
tmux new-window  -t e:1 -n home   'cd ~; bash -i'
tmux new-window  -t e:2 -n log   'cd /var/log; bash -i'

tmux select-window -t e:1
tmux -2 attach-session -t e

如果你只是想把屏幕分成2个窗格(水平),你可以运行这个命令(不需要tmux或shell脚本):

tmux new-session \; split-window -h \;

你的屏幕会是这样的:

[ks@localhost ~]$                      │[ks@localhost ~]$ 
                                       │
                                       │
                                       │
                                       │
                                       │
                                       │
                                       │
                                       │
                                       │
                                       │
                                       │
[10] 0:ks@localhost:~*                  "localhost.localdomain" 19:51 31-янв-16

有一个tmux插件。

查看tmux- resurrection

Restore tmux environment after system restart. Tmux is great, except when you have to restart the computer. You lose all the running programs, working directories, pane layouts etc. There are helpful management tools out there, but they require initial configuration and continuous updates as your workflow evolves or you start new projects. tmux-resurrect saves all the little details from your tmux environment so it can be completely restored after a system restart (or when you feel like it). No configuration is required. You should feel like you never quit tmux.

或tmux-continuum

特点: 持续节约tmux环境 当计算机/服务器打开时自动启动tmux tmux启动时自动恢复