要求: 于tmux内部链接ssh什么时候, 假设有多个ssh主机。 我们要显示相应的主机ip要显示筛查

实现效果

编辑你的bashrc, 由于我习惯在root下操作, 所以/root/.bashrc。 你假设习惯用user。 那就编辑/home/你的username/.bashrc

添加

ssh() {

    if [ "$(ps -p $(ps -p $$ -o ppid=) -o comm=)" = "tmux" ]; then

            tmux rename-window "$*"

            command ssh "$@"

            tmux set-window-option automatic-rename "on" 1>/dev/null

    else

            command ssh "$@"

    fi

}

到你的bashrc

保存后就可以。

唯一须要注意的是。由于我习惯ssh -參数 參数值 root@ip 这样来訪问, 由于改动了ssh的这个。导致參数值会无法正常识别。这里把參数參数值放到后面就可以。

附tmux.conf配置

#bind r source-file ~/.tmux.conf \;display "Reloaded!"

# #      重置预设置

set -g prefix C-a               #设置命令为ctrl-a触发prefix

unbind C-b                      #解绑ctrl-b

bind C-a send-prefix            #设置预命令为prefix





# #      面板切割

unbind '"'

bind | split-window -h          #左右切割

unbind %

bind - split-window -v          #上下切割





bind k select-pane -U           #选择上窗体 shift+k

bind j select-pane -D           #选择下窗体

bind h select-pane -L           #选择左窗体

bind l select-pane -R           #选择右窗体





bind K resize-pane -U 5         #窗格上移5  (Ctrl-k一起按)

bind J resize-pane -D 5         #窗格下移5

bind H resize-pane -L 5         #窗体左移5

bind L resize-pane -R 5         #窗体右移5





bind -r K resize-pane -U 5      #窗体反复操作

bind -r J resize-pane -D 5      #窗体反复操作

bind -r H resize-pane -L 5      #窗体反复操作

bind -r L resize-pane -R 5      #窗体反复操作









bind ^u swapp -U                #与上窗格交换   (Ctrl-u)

bind ^d swapp -D                #与下窗格交换   (Ctrl-u)





# # enable vi keys.

setw -g mode-keys vi            #兼容vi按键





# #      像vi一样复制    全部复制都会被记录在缓冲区,输入#或tmux list-buffers查看,=也能够选择粘贴缓冲区

unbind [

bind Escape copy-mode           #绑定Esc进入复制模式

#unbind p                        #解绑p

bind P paste-buffer             #绑定p为粘贴

bind -t vi-copy 'v' begin-selection #绑定v为选择

bind -t vi-copy 'y' copy-selection  #绑定y为复制





#setting the delay between PREFIX and command

set -sg escape-time 1









# # Set the base index for windows to 1 instead of 0

set -g base-index 1





# # Set the base index for panes to 1 instead of 0

setw -g pane-base-index 1





# #      又一次载入配置文件

bind r source-file /etc/tmux.conf \; display "Reloaded!"









# # Quick pane selection        #Prefix+Ctrl+h/l循环windows

bind -r C-h select-window -t :-

bind -r C-l select-window -t :+









# # mouse support - set to on if you want to use the mouse

setw -g mode-mouse off

set -g mouse-select-pane off

set -g mouse-resize-pane off

set -g mouse-select-window off





# # Set the default terminal mode to 256color mode

set -g default-terminal "screen-256color"

set -g display-time 2000

set -g history-limit 10000





# # enable activity alerts

setw -g monitor-activity on

set -g visual-activity on





# # set the status line's colors

set -g status-fg white

set -g status-bg black





# # set the color of the window list

setw -g window-status-fg cyan

setw -g window-status-bg default

setw -g window-status-attr dim





# # set colors for the active window

setw -g window-status-current-fg white

setw -g window-status-current-bg red

setw -g window-status-current-attr bright





# # pane colors

set -g pane-border-fg white

set -g pane-border-bg black

set -g pane-active-border-fg blue

#set -g pane-active-border-bg colour240





# # Command / message line

set -g message-fg white

set -g message-bg black

set -g message-attr bright





# # Status line left side

set -g status-left-length 20

set -g status-left "#[fg=green]Session: #S #[fg=yellow]#I #[fg=cyan]#P"

set -g status-utf8 on





# # Status line right side

# # 15% | 28 Nov 18:15

set -g status-right "#[fg=cyan]%Y-%m-%d %H:%M:%S "





# # Update the status bar every sixty seconds

set -g status-interval 60





# # Center the window list

set -g status-justify centre





# # Maximize and restore a pane

unbind Up

bind Up new-window -d -n tmp \; swap-pane -s tmp.1 \; select-window -t tmp

unbind Down

bind Down last-window \; swap-pane -s tmp.1 \; kill-window -t tmp





# # Working with the Clipboard on Linux

bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"

bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

版权声明:本文博主原创文章。博客,未经同意不得转载。

bash构造tmux显示tmux ssh状态的更多相关文章

  1. SQL Server系统视图sys.master_files不能正确显示数据库脱机状态

    最近发现在SQL Server数据库(目前测试过SQL Server 2008, 2012,2014,2016各个版本)中,即使数据库处于脱机(OFFLINE)状态,但是sys.master_file ...

  2. 20181225-Linux Shell Bash环境下自动化创建ssh互信脚本

    20181225-Linux Shell Bash环境下自动化创建ssh互信脚本 1. 我的Blog 博客园 https://www.cnblogs.com/piggybaba/ 个人网站 http: ...

  3. 实例节点的NTP服务器地址配置正确,而且能够ping通, 但是在chronyc sources指令中显示NTP服务器状态为“?”

    问题:如果实例节点的NTP服务器地址配置正确,而且能够ping通,   但是在chronyc sources指令中显示NTP服务器状态为“?”, 该如何检查并操作. 1)在chrony配置文件中,检查 ...

  4. pwd命令和修改PS1环境变量在bash行的显示

    一.pwd:显示当前所在的位置 语法 pwd [选项] ... 描述       打印当前工作目录的完整文件名. -L,--logical              从环境使用PWD,即使它包含符号链 ...

  5. git bash中不能显示中文

    git bash中不能显示中文 问题描述:当使用git log查看提交日志时,中文字符不能正常显示问题 1.首先把git的配置改一下 git config --global core.quotepat ...

  6. Centos-配置网络或显示当前网络接口状态-ifconfig

    ifconfig 配置网络或显示当前网络接口状态,必须由root用户执行 相关选项 -a 显示所有网络接口信息,包括活动或非活动 -s 显示活动接口简要信息 -v 如果网卡接口出现错误则返回错误信息 ...

  7. 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态。点击列表的项,切换二级列表的显示或隐藏状态

    查看本章节 查看作业目录 需求说明: 使用jQuery 中的显示与隐藏动画效果实现折叠下拉菜单的收缩和展开,在页面的列表中有若干项,列表的每项中有一个二级列表,二级列表默认为隐藏状态.点击列表的项,切 ...

  8. ASP.net中GridView中增加一行记录并默认显示为编辑状态

    //添加 protected void Button1_Click(object sender, EventArgs e) { DataSet ds = (DataSet)pa.GetDataSet( ...

  9. Linux 命令 - jobs: 显示后台作业的状态信息

    命令格式 jobs [-lnprs] [jobspec ...] jobs -x command [args] 命令参数 -l 额外显示作业的进程 ID. -n 只列出状态发生变化的进程. -p 只列 ...

随机推荐

  1. MSF连环攻击实验

    MSF连续攻击实验 一.实验拓扑 二.实验环境 Windows XP BT 5 32位 三.实验原理 通过扫描 XP主机,利用扫描出的漏洞建立 TCP会话,通过进程的提权,进一步获取目标机的控制权限 ...

  2. R 语言开发环境搭建

    R 语言在统计计算和画图方面有着显著的优势,因此在大数据领域也有其一席之地. 本文将演示怎样搭建R 语言开发环境. 搭建R 语言开发环境,主要有两个步骤: - 安装 R 到操作系统 - 安装支持 R ...

  3. 使用Nexus搭建企业maven仓库(二)

    先阅读<使用Nexus搭建企业maven仓库(一)> http://blog.csdn.net/ouyida3/article/details/40747545 1.官网眼下最新的版本号是 ...

  4. UVA 11490 - Just Another Problem(数论)

    11490 - Just Another Problem option=com_onlinejudge&Itemid=8&page=show_problem&category= ...

  5. Cocos2d-x3.0下一个 Lua与C++打电话给对方

    这里谈下Lua与C++如何实现相互通话 原来的连接:http://blog.csdn.net/qqmcy/article/details/26052771 DJLCData.h 实现类 // // D ...

  6. VMware3种网络模式

     VMware网络配置详解一:三种网络模式简介 安装好虚拟机以后,在网络连接里面可以看到多了两块网卡: 其 中VMnet1是虚拟机Host-only模式的网络接口,VMnet8是NAT模式的网络接口, ...

  7. java注解(一)

    虽然平时有使用注解,不过没有深入了解,今天无聊,重新从基础深入了解整理下: java注解是附加在代码中的一些元信息,用于一些工具在编译.运行时进行解析和使用,起到说明.配置的功能.     注解不会也 ...

  8. C++-传值与传引用的差别

    //值传递与引用传递的差别 #include <iostream> #include <iomanip> using namespace std; void fiddle(in ...

  9. Shine we together: A innovative dating site using 2012 Nobel Laureate Roth's algorithm

    Abstract Our dating site introduced scoring and its related functionalities innovatively, conforming ...

  10. 动画(Animation) 它 (闪烁、左右摇摆、跷跷板等功效)

    一侧到另一侧的影响: (这里显示的是并不那么顺利) 一.续播  (不知道取什么名字好,就是先播放动画A, 接着播放动画B) 有两种方式. 第一种.分别动画两个动画,A和B, 然后先播放动画A,设置A ...