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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • mac idea 2021激活码【2021免费激活】

    (mac idea 2021激活码)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.htmlS32PGH0SQB-eyJsaWNlbnNlSWQi…

    2022年3月26日
    47
  • 出生率新低!1978-2020中国人口出生率、死亡率及自然增长率变迁「建议收藏」

    出生率新低!1978-2020中国人口出生率、死亡率及自然增长率变迁「建议收藏」根据国家统计局近日发布的《中国统计年鉴2021》,2020中国人口出生率为8.52‰,再创历史新低。同时,2020中国人口自然增长率仅为1.45‰,勉强维持正增长,同样是历史新低。下面的视…

    2022年9月5日
    18
  • Request对象详细介绍「建议收藏」

    Request对象详细介绍「建议收藏」在做Web端程序开发时,少不了与这两个内置对象打交道。可以说整个客户端与服务端之间的交互都是通过这两个内置对象做关联,下面来详细的说一下。 1.Request对象 该对象用来在服务器端处理客户端发送的请求。 我们可以了解request对象是当客户端向服务端发送请求后,服务器为本次请求创建request对象,并调用

    2022年5月3日
    42
  • currentstyle 织梦_织梦arclist标签支持高亮currentstyle属性方法

    currentstyle 织梦_织梦arclist标签支持高亮currentstyle属性方法找到include/taglib/arclist.lib.php第一步:查找:$channelid=$ctag->GetAtt(‘channelid’);替换:$channelid=$ctag->GetAtt(‘channelid’);$currentstyle=$ctag->GetAtt(‘currentstyle’);第二步:查找:$ct…

    2022年7月14日
    13
  • java主要用来开发什么_浅谈Java开发主要是用来做什么的?

    java主要用来开发什么_浅谈Java开发主要是用来做什么的?java是一种编程语言,所以当然是用来“创造”的啦。它能做的事情非常多,涵盖了编程领域的方方面面。1、桌面级应用,简单来说就是主要功能都在计算机上运行的程序,比如word、excel等办公软件就归为此类。2、企业级应用(应用最广泛),简单来说就是,使用人数较多,数据量较大的应用。它对系统的稳定性、安全性、扩展性等要求较高。包括HR管理软件、营销管理软件、等几乎所有你能想到的应用。3、嵌入式设备及…

    2022年7月7日
    19
  • mysql longtext查询慢_select中的longtext使查询速度极慢

    mysql longtext查询慢_select中的longtext使查询速度极慢我有一个结构如下的普通平台CREATETABLE`oc_pipeline_logging`(`id`INT(11)NOTNULLAUTO_INCREMENT,`source`TEXT,`comments`TEXT,`data`LONGTEXT,`query`TEXT,`date_added`TIMESTAMPNOTNULLDEFAULTCURRENT_TIMESTA…

    2022年5月14日
    103

发表回复

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

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