tmux 如何自定义背景颜色 | How does the tmux color palette work?

tmux 如何自定义背景颜色 | How does the tmux color palette work?坑1:256colorsupportforvimbackgroundintmuxhttps://superuser.com/questions/399296/256-color-support-for-vim-background-in-tmux原因Fromthelookofyour.bashrcand.profile,theshellsinsidetmuxareoverridingthe‘default-terminal’settinginyour

大家好,又见面了,我是你们的朋友全栈君。

坑1:256 color support for vim background in tmux

解决终端颜色配置与 tmux 颜色配置不匹配问题。

https://superuser.com/questions/399296/256-color-support-for-vim-background-in-tmux

原因

From the look of your .bashrc and .profile, the shells inside tmux are overriding the ‘default-terminal’ setting in your tmux conf. Something like this:

  • tmux creates new shell with TERM=screen-256color
  • .bashrc/.profile run, set TERM=xterm-256color
  • vim runs, tries to use incorrect TERM for tmux

you can check this by running

echo $TERM

in a fresh tmux shell.

Tmux is relatively picky about having a terminal set correctly. If you can, set the term value in gnome-terminal’s configuration, not in your .bashrc. Failing that, surround those settings with a check for “screen” or “screen-256color” TERM, and don’t reset them in that case.

Tmux REALLY wants the terminal set to screen or screen-256color

解决方法

This is what worked for me in #Ubuntu and #Mac:

# File: ~/.bashrc (Ubuntu), ~/.bash_profile (Mac)
# for VIM and TMUC
if [ "$TERM" = "xterm" ]; then
  export TERM=xterm-256color
fi
alias tmux='tmux -2'  # for 256color
alias tmux='tmux -u'  # to get rid of unicode rendering problem

Reload settings:

$ source ~/.bashrc # Ubuntu

$ source ~/.bash_profile # Mac

Set up .bashrc for Mac (as it is used by tmux)

# File: ~/.bashrc (Mac)
source ~/.bash_profile

Set up “default-terminal” option in ~/.tmux.conf.

# File: ~/.tmux.conf
set -g default-terminal "screen-256color"  # Mac and Ubuntu

坑 2:Change background color of active or inactive pane in Tmux

详解 .tmux.conf 配置文件设置背景颜色的方法。其中,fg 是字体颜色,bg 是背景颜色。

https://newbedev.com/change-background-color-of-active-or-inactive-pane-in-tmux

It seems that tmux-2.1 (released 18 October 2015) now allows the colours of individual panes to be specified. From the changelog:

* 'select-pane' now understands '-P' to set window/pane background colours.

e.g. [from the manual] to change pane 1’s foreground (text) to blue and background to red use:

select-pane -t:.1 -P 'fg=blue,bg=red'

To mimic iTerm colour scheme:

To answer the original question, I use the following lines in my ~/.tmux.conf for setting the background/foreground colours to mimic the behaviour in iTerm:

#set inactive/active window styles
set -g window-style 'fg=colour247,bg=colour236'
set -g window-active-style 'fg=colour250,bg=black'

# set the pane border colors 
set -g pane-border-style 'fg=colour235,bg=colour238' 
set -g pane-active-border-style 'fg=colour51,bg=colour236'

坑 3:Reloading tmux config

写完配置文件后,需要手动 source 使其生效。

https://blog.sanctum.geek.nz/reloading-tmux-config/,Posted on 2012-03-19

If you have made changes to your tmux configuration file in the ~/.tmux.conf file, it shouldn’t be necessary to start the server up again from scratch with kill-server. Instead, you can prompt the current tmux session to reload the configuration with the source-file command.

This can be done either from within tmux, by pressing Ctrl+B and then : to bring up a command prompt, and typing:

:source-file ~/.tmux.conf

Or simply from a shell:

$ tmux source-file ~/.tmux.conf

This should apply your changes to the running tmux server without affecting the sessions or windows within them.

This entry was posted in Tmux and tagged configuration, reload, source, source-file, tmux.conf by Tom Ryder. Bookmark the permalink.


附:tmux 配置中的 colour0~255 颜色表

You can create it with for i in {0..255}; do printf "\x1b[38;5;${i}mcolor%-5i\x1b[0m" $i ; if ! (( ($i + 1 ) % 8 )); then echo ; fi ; done
在这里插入图片描述

配置文件:
在这里插入图片描述

效果:

在这里插入图片描述

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/151786.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • stat函数百度百科_strel函数

    stat函数百度百科_strel函数stat函数的简单使用stat函数是用来获取文件的各种属性的一个linux下的常用API函数。函数原型为intstat(constchar*path,structstat*buf);stat定义如下:structstat{dev_tst_dev;//文件的设备编号ino_tst_ino;//节点mode_tst_m…

    2022年8月21日
    7
  • dnf自己搭建服务器_dnf搭建教程

    dnf自己搭建服务器_dnf搭建教程DNF游戏私服搭建过程准备资源:1.黑岩客户端2.服务器启动所需资源3.1核2G服务器一台(版本centos5.8)(记得开放全部端口)服务端配置:步骤一:切换源为163的源:wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.163.com//.help/CentOS5-Base-163.repo上传资源到服务器的根目录cd/上传文件步骤二:安装glibc.i386,xulrunner.i386,libXt

    2022年10月5日
    3
  • Vim:如何退出Vim编辑器?

    Vim:如何退出Vim编辑器?Vim:如何退出Vim编辑器?(笑)这个问题可以说是每个初学者的必经之路咯解决办法如下!请注意非常重要的一点!在vim里面不管何时,直接输入“:”就会在最下面显示出一行,vim开始进入命令模式(而不是write模式)当初自己傻得不行,明知道命令却不知道如何使用,分享给那些一样和我不知道怎么使用命令的…:q//退出:q!//退出且不保存(:quit!的缩写):wq//保存并退出:wq!//保存并退出即使文件没有写入权限(强制保存退出):x//保存并退出(类似:w

    2022年6月5日
    69
  • 深圳易速马网络科技有限公司_动易网络

    深圳易速马网络科技有限公司_动易网络纵观现如今国内CMS程序,大有百花争艳的感觉,随着企业建站需求的复杂度和功能的不断扩展,传统的三五个人写一段代码即告网站建已经行不通,于是以内容管理为应用核心的CMS产品大行其道。  这些CMS系统大体上基于两套框架编写:PHP+MySQL和.NET+MSSQL。在PHP中比较有名的就有DeDeCMS、PHP168、帝国CMS、Supesite等,在.NET方面就有zoomla!CMS、

    2022年9月30日
    5
  • 压力换算公斤单位换算_压力单位换算表

    压力换算公斤单位换算_压力单位换算表压力单位换算表来源:华强电子网作者:华仔浏览:1163时间:2016-08-1014:18标签:摘要:november6,2002牛顿/米2(帕斯卡)(n/m2)(pa)公斤力/米2(kgf/m2)公斤力/厘米2(kgf/cm2)巴(bar)标准大气压(atm)毫米水柱4oc(mmh2o)毫米水银柱0oc(mmhg)磅/英寸2(lb/in2,psi)牛顿/米2(帕斯卡)(n…

    2022年7月27日
    15
  • 如何解决vscode感叹号无法建立html文件的问题

    如何解决vscode感叹号无法建立html文件的问题今天是我使用vscode的第二天,没想到昨天还能用感叹号(!)建立文件模板的vscode今天却不行了,而且中途也重装过一次。虽然重装后能用感叹号(!)弄一个模板出来,但是在此新建文件的时候就没用了。所以我一直在思索为什么会这样,最终功夫不负有心人还是给我找到了。在此,谢谢那位给我指名方向的大佬。正确方法是输入html:5,然后回车就能出现模板了。因为vscode升级了,所以关于模板的设定可能出现了一些变化吧。在这里恳求大家了,如果各位读者觉得好用的话就动动小手点赞吧。拜托了。…

    2022年8月22日
    11

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号