〖Linux〗在tmux同时使用bash和zsh
个人有两份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的更多相关文章
- linux、mac的bash和zsh如何切换
1.hostname 192-23-2-2 修改主机名字 2.chsh -s /bin/bash和chsh -s /bin/zsh可以永久切换,也就是一登录进来的就是相应的界面 bash/zsh命令是 ...
- Linux之tmux学习
Linux之tmux学习 前言 在Linux的世界中,命令行是最优雅的交互方式. 但是,只会使用一个交互终端的程序员,是不足以成为Linux下的大牛的. 那么tmux是什么,引用一下原文介绍 tmux ...
- shell自动补全功能:bash和zsh
首要一点:shell有多种,比如bash.zsh.csh.ksh.sh.tcsh等 因此,制作自动补全功能时,要先搞清楚,你使用的是哪种shell,各个shell制作方法是不同的,网上大部分介绍的是关 ...
- Linux编程 3 (初识bash shell与man查看手册)
一.初识bash shell 1.1 启动 shell GNU bash shell 能提供对Linux系统的交互式访问.通常是在用户登录终端时启动,登录时系统启动shell依赖于用户账户的配置. ...
- Linux下通过受限bash创建指定权限的账号
在日常业务运维中,有时为了配合解决问题,需要给非运维人员开通系统账号,用于查询日志或代码.通常为了系统安全或避免不必要的误操作等目的,会将账号权限降至最低.下面介绍下在Linux下通过受限bash创建 ...
- Mac zsh切换bash bash切换zsh
切换bash ————>>>chsh -s /bin/bash 切换zsh ------->>>chsh -s /bin/zsh
- Bash 和 Zsh 开启 vi-mode
Bash 和 Zsh 开启 vi-mode bash 有两种操作模式,分别是 emacs 和 vi . 在 bash 中 set -o vi # 临时开启 vi 模式 vi ~/.bashrc # 在 ...
- zsh切换bash bash切换zsh
切换bash(需要sudo) chsh -s /bin/bash 切换zsh(不需要sudo) chsh -s /bin/zsh 注意:如果输入命令和密码后提示:no change made. 请加上 ...
- bash和zsh切换
zsh切换bash bash切换zsh 切换bash chsh -s /bin/bash 切换zsh chsh -s /bin/zsh
随机推荐
- Kubernetes基础
Kubernetes是什么 Kubernetes是当今最流行的开源容器管理平台,它就是大名鼎鼎的Google Borg的开源版本.Google在2014年推出了Kubernetes,本文发布时最新的版 ...
- Java命令学习系列(五)——jhat
jhat(Java Heap Analysis Tool),是一个用来分析java的堆情况的命令.之前的文章讲到过,使用jmap可以生成Java堆的Dump文件.生成dump文件之后就可以用jhat命 ...
- 使用jupyter搭建golang的交互式界面:类似于ipython;jupyter还可以使用spark或者结合机器学习
Jupyter Notebook The Jupyter notebook is a web-based notebook environment for interactive computing. ...
- 【UOJ Round #5】
构造+贪心/数论 为什么只有两个标题呢……因为第二题我不会…… 怎样提高智商 构造题……然而一开始半天我都yy不出来…… 后来我想:这题应该不会特别麻烦,而且既然样例只给了1,可能再给大一点就让人发现 ...
- Qt实现自定义按钮的三态效果
好久之前做的一个小软件,好长时间没动过了,在不记录下有些细节可能都忘了,这里整理下部分功能的实现. 按钮的三态,指的是普通态.鼠标的停留态.点击态,三态是界面交互非常基本的一项功能,Qt中如果使用的是 ...
- postgresql共享内存的三个结构体
本文原创为freas_1990,转载请标明出处:http://blog.csdn.net/freas_1990/article/details/16105797 postgresql的共享内存维护主要 ...
- 纯css解决div隐藏浏览器原生滚动条,但保留鼠标滚动效果的问题
当我们的内容超出了我们的div,往往会出现滚动条,影响美观.尤其是当我们在做一些导航菜单的时候.滚动条一出现就破坏了UI效果. 我们不希望出现滚动条,也不希望超出去的内容被放逐,就要保留鼠标滚动的效 ...
- window.location属性用法及解决一个window.location.search为什么为空的问题
通常用window.location该属性获取页面 URL 地址: 1.什么是window.location? 比如URL:http://b.a.com:88/index.php?name=kang& ...
- LSTM简介以及数学推导(FULL BPTT)
http://blog.csdn.net/a635661820/article/details/45390671 前段时间看了一些关于LSTM方面的论文,一直准备记录一下学习过程的,因为其他事儿,一直 ...
- postgres配置只能让某一个ip的主机登陆
https://stackoverflow.com/questions/11753296/configure-postgresql-to-work-for-only-localhost-or-spec ...