个人有两份tmux配置文件:

  ~/.tmux.conf # 使用zsh,主要是日常使用,zsh太好使用了

  ~/.tmux.conf.bash # 使用bash,主要是Android编译使用

按照tmux的man手册,可以使用 -f config_file 来指定tmux使用的配置文件,于是:

alias ta='tmux -f ~/.tmux.conf attach -t'
alias tab='tmux -f ~/.tmux.conf.bash -L bash attach -t'
alias tl='tmux list-sessions'
alias ts='tmux -f ~/.tmux.conf new-session -s'
alias tsb='tmux -f ~/.tmux.conf.bash -L bash new-session -s'

但是发现怎么也不能够同时使用bash和zsh:

  一旦使用了配置 ~/.tmux.conf 启动一个session之后,

  再使用配置文件 ~/.tmux.conf.bash 怎么也是启动了zsh,而不是期望的bash;

于是再仔细看看tmux使用的文件:

  lsof -c tmux

 COMMAND  PID   USER   FD   TYPE             DEVICE SIZE/OFF   NODE NAME
tmux sinfor cwd DIR , /home/sinfor
tmux sinfor rtd DIR , /
tmux sinfor txt REG , /usr/bin/tmux
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libnss_files-2.19.so
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libnss_nis-2.19.so
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libnsl-2.19.so
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libnss_compat-2.19.so
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libpthread-2.19.so
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libc-2.19.so
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libresolv-2.19.so
tmux sinfor mem REG , /usr/lib/x86_64-linux-gnu/libevent-2.0.so.5.1.
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libtinfo.so.5.9
tmux sinfor mem REG , /lib/x86_64-linux-gnu/libutil-2.19.so
tmux sinfor mem REG , /lib/x86_64-linux-gnu/ld-2.19.so
tmux sinfor 0u CHR , 0t0 /dev/null
tmux sinfor 1u CHR , 0t0 /dev/null
tmux sinfor 2u CHR , 0t0 /dev/null
tmux sinfor 3u unix 0x0000000000000000 0t0 socket
tmux sinfor 4u unix 0x0000000000000000 0t0 socket
tmux sinfor 6u unix 0x0000000000000000 0t0 /tmp/tmux-/default
tmux sinfor 8u CHR , 0t0 /dev/ptmx
tmux sinfor 9u CHR , 0t0 /dev/ptmx
tmux sinfor 10u CHR , 0t0 /dev/ptmx
tmux sinfor 11u CHR , 0t0 /dev/ptmx
tmux sinfor 12u CHR , 0t0 /dev/ptmx
tmux sinfor 13u CHR , 0t0 /dev/ptmx
tmux sinfor 14u CHR , 0t0 /dev/ptmx

lsof -c tmux

  发现/tmp/tmux-1000/default有点蹊跷,于是再仔细看看man文档,其中包含socket的描述如下:

      -L socket-name
tmux stores the server socket in a directory under /tmp (or TMPDIR if set); the default socket is
named default. This option allows a different socket name to be specified, allowing several inde‐
pendent tmux servers to be run. Unlike -S a full path is not necessary: the sockets are all cre‐
ated in the same directory.
-S socket-path
Specify a full alternative path to the server socket. If -S is specified, the default socket
directory is not used and any -L flag is ignored.

man tmux socket

  仔细分析了一下这里的信息,原来在未指定socket文件(-L)或路径(-S)时,都默认使用了同一个socket,man描述中还提到:

 In tmux, a session is displayed on screen by a client and all sessions are managed by a single server.  The
server and each client are separate processes which communicate through a socket in /tmp.

man tmux socket

  所以,正是因为他们都使用了这个/tmp/tmux-1000/default,导致了指定配置文件对于新开的session无效;

解决方法:  

 alias ts='tmux -f ~/.tmux.conf -L zsh new-session -s'
alias tsb='tmux -f ~/.tmux.conf.bash -L bash new-session -s'
alias tl='tmux -L zsh list-sessions|sed "s/^/[zsh] /g"; tmux -L bash list-sessions|sed "s/^/[bash] /g"'

OK,大功告成,Enjoy!

〖Linux〗在tmux同时使用bash和zsh的更多相关文章

  1. linux、mac的bash和zsh如何切换

    1.hostname 192-23-2-2 修改主机名字 2.chsh -s /bin/bash和chsh -s /bin/zsh可以永久切换,也就是一登录进来的就是相应的界面 bash/zsh命令是 ...

  2. Linux之tmux学习

    Linux之tmux学习 前言 在Linux的世界中,命令行是最优雅的交互方式. 但是,只会使用一个交互终端的程序员,是不足以成为Linux下的大牛的. 那么tmux是什么,引用一下原文介绍 tmux ...

  3. shell自动补全功能:bash和zsh

    首要一点:shell有多种,比如bash.zsh.csh.ksh.sh.tcsh等 因此,制作自动补全功能时,要先搞清楚,你使用的是哪种shell,各个shell制作方法是不同的,网上大部分介绍的是关 ...

  4. Linux编程 3 (初识bash shell与man查看手册)

    一.初识bash shell 1.1 启动 shell   GNU bash shell 能提供对Linux系统的交互式访问.通常是在用户登录终端时启动,登录时系统启动shell依赖于用户账户的配置. ...

  5. Linux下通过受限bash创建指定权限的账号

    在日常业务运维中,有时为了配合解决问题,需要给非运维人员开通系统账号,用于查询日志或代码.通常为了系统安全或避免不必要的误操作等目的,会将账号权限降至最低.下面介绍下在Linux下通过受限bash创建 ...

  6. Mac zsh切换bash bash切换zsh

    切换bash    ————>>>chsh -s /bin/bash 切换zsh      ------->>>chsh -s /bin/zsh

  7. Bash 和 Zsh 开启 vi-mode

    Bash 和 Zsh 开启 vi-mode bash 有两种操作模式,分别是 emacs 和 vi . 在 bash 中 set -o vi # 临时开启 vi 模式 vi ~/.bashrc # 在 ...

  8. zsh切换bash bash切换zsh

    切换bash(需要sudo) chsh -s /bin/bash 切换zsh(不需要sudo) chsh -s /bin/zsh 注意:如果输入命令和密码后提示:no change made. 请加上 ...

  9. bash和zsh切换

    zsh切换bash bash切换zsh 切换bash chsh -s /bin/bash 切换zsh chsh -s /bin/zsh

随机推荐

  1. LaTeX使用技巧

    使用LaTex的方法: (1)推荐一个手写公式.自动生成LaTex的网站——Web Equation. (2)如果会LaTex,可以直接用在线LaTex编辑 (3)从mathtype转换: 首先打开文 ...

  2. Java Type Inference (类型推断)

    public class Test2 { public static void main(String[] args) { ArrayList<String> list = newArra ...

  3. CSS 强制换行和禁止换行强制换行 和禁止换行样式

    强制换行 1.word-break: break-all;       只对英文起作用,以字母作为换行依据. 2.word-wrap: break-word;   只对英文起作用,以单词作为换行依据. ...

  4. CF 329C(Graph Reconstruction-随机化求解-random_shuffle(a+1,a+1+n))

    C. Graph Reconstruction time limit per test 3 seconds memory limit per test 256 megabytes input stan ...

  5. ARM、X86/Atom、MIPS、PowerPC

    关注Android的时候,有一些CPU架构方面的术语知识,主要有:ARM.X86/Atom.MIPS.PowerPC1)ARM/MIPS/PowerPC均是基于精简指令集(RISC,Reduced I ...

  6. Set Matrix Zeroes leetcode java

    题目: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. cl ...

  7. 理解TensorFlow的Queue

    https://www.jianshu.com/p/d063804fb272 这篇文章来说说TensorFlow里与Queue有关的概念和用法. 其实概念只有三个: Queue是TF队列和缓存机制的实 ...

  8. FastText 文本分类使用心得

    http://blog.csdn.net/thriving_fcl/article/details/53239856 最近在一个项目里使用了fasttext[1], 这是facebook今年开源的一个 ...

  9. 用深度学习(CNN RNN Attention)解决大规模文本分类问题 - 综述和实践

    https://zhuanlan.zhihu.com/p/25928551 近来在同时做一个应用深度学习解决淘宝商品的类目预测问题的项目,恰好硕士毕业时论文题目便是文本分类问题,趁此机会总结下文本分类 ...

  10. Cognos11中关于CJAP第三方认证的相关配置

    cognos11同样适用于自定义java程序的第三方认证,而且在测试方面给了直观的测试接口,如下图所示 当用户配置好了自定义java程序的认证之后,程序会提示用户输入我们自己的认证库用户信息例如adm ...