坑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" ]; thenexport 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

配置文件:

效果:

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

  1. Pycharm如何设置自定义背景颜色

    Pycharm可以通过设置主题来设定背景颜色,但主题的背景颜色也仅仅局限特定的几种,通过如下的方式可以自定义背景颜色. File--Settings--Editor--General--(右侧上方的框 ...

  2. easyExcel自定义背景颜色easyPoi自定义修改表头背景色

    背景:Excel自定义背景颜色,自定义表头背景颜色 注意点:单元格设置背景颜色失效原因/不生效的原因,通常是因为只设置了setFillForegroundColor 参数,这样肯定是不行的,还需要再设 ...

  3. 【Typora】 自定义背景颜色(护眼绿) 高亮颜色 选中内容颜色 高亮快捷键

    自定义背景颜色.选中内容背景颜色.高亮标记内容颜色 注意查看当前使用的主题 拉到最下面,添加如下代码: content {background-color: #CCE8CF; }mark {backg ...

  4. android 圆角颜色背景,android自定义控件之可自定义背景颜色的圆角textview

    8种机械键盘轴体对比 本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选? 2016-07-12 前言 最近在做一个需求,就是实现一个可以自定义背景颜色,并且是圆角的TextView,如下图: 这 ...

  5. Poi 4.0设置自定义背景颜色

    /*设置背景颜色*/ cellBoldStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); HSSFPalette palette = wb. ...

  6. jQuery获取div的背景颜色 How to get background color of div?

    直接代码: <script type="text/javascript"> $(document).ready(function(){$("div" ...

  7. Element-UI表格自定义背景颜色

    笔记 1.如图所示 2. 自定义样式 此处自定义设置时要加 /deep/.important,否则不生效: <style scoped="scoped"> // 更改表 ...

  8. 基于Hutool工具来设置Excel一个单元格自定义背景颜色

    设置未生效 一开始,cell设置背景颜色不起作用,代码为: cellStyle.setFillBackgroundColor(IndexedColors.BRIGHT_GREEN1.getIndex( ...

  9. python xlwt设置单元格的自定义背景颜色

    我使用python 2.7和xlwt模块进行excel导出 我想设置我知道可以使用的单元格的背景颜色 style1 = xlwt.easyxf('pattern: pattern solid, for ...

最新文章

  1. Activex、OLE、COM、OCX、DLL之间区别、联系
  2. 程序员计算器_GitHub 日收 7000 星,Windows 计算器项目开源即爆红!
  3. hello word 程序 ——简单的spring ioc 学习
  4. 浏览器中遮罩层镂空效果的多种实现方法
  5. Ubuntu gbk,utf-8 转换
  6. 20应用统计考研复试要点(part25)--简答题
  7. 获取访客进站关键词_拼多多访客突然下降是为什么?拼多多访客突然暴涨又是怎么回事?...
  8. 华为“方舟编译器”到底是啥?一文看懂TA如何让手机性能再突破
  9. jinja2模板注入_Flask jinja2 模板注入思路总结
  10. 内向的人能做管理吗?
  11. 中兴 108 亿换得自由身!
  12. json返回的img图片被原样输出_爬取百度图片,并下载至本地
  13. install 命令用法详解
  14. pdf如何转化成word文档?
  15. poj 1129 四色原理DFS
  16. matlab生成空图像,figure,imshow之后图像为空白图像
  17. MQ延迟队列实现延迟消息
  18. Ubuntu 16.10 禁用 Guest 访客模式
  19. Matlab中常用的几个清除命令
  20. MIR DATABANK自动化和智能制造每周要闻 —2019年10月15日

热门文章

  1. CodeForces - 125C Hobbits' Party(思维+构造)
  2. 排序算法-01冒泡排序(Python实现)
  3. 小学计算机课程表说课稿,小学信息技术《制作课程表》说课稿.doc
  4. Vi(Linux系统下的标准编辑器)学习笔记
  5. Windows下使用ffmpeg为视频添加字幕
  6. 逆向工程核心原理学习笔记(八):小端序标记法1
  7. (十)boost库之多线程
  8. 【Boost】boost库asio详解1——io_service::run函数无任务时退出的问题
  9. 并发编程中常见的锁机制:乐观锁、悲观锁、CAS、自旋锁、互斥锁、读写锁
  10. 记一次kubect init初始化端口占用问题