terminal bash 颜色的详细解释
http://evadeflow.com/2010/06/sane-terminal-colors/
Sane Terminal Colors
June 26, 2010
I recently created a new Ubuntu VM and once again found myself not liking the default terminal colors when I aliased ‘ls’ to ‘ls –color=auto’. I must’ve looked up how to customize this a dozen times, and done it slightly differently each time. Here, for reference, is what I did this time.
- Add these lines to my .zshrc:
eval $(dircolors -b ~/.dircolors)
alias ls='ls -hF --color=auto' - Run this command: dircolors -p > ~/.dircolors
- Modify ~/.dircolors to emit the colors I want it to
- Modify the gnome-terminal profile colors so they don’t look so garish
The trick is understanding that these colors (from ~/.dircolors):
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
and their bold variants map directly to the colors shown in gnome-terminal’s Colors dialog: So, if the thing called out as ‘green’ in your dircolors config is too DayGlo for you, just use the above dialog to select a darker color for the GREEN ‘slot’. Or even a completely different color. (The color doesn’t have to match the name; you could modify the MAGENTA slot to be dark blue, for example.)
The colors in the bottom row of the palette represent the colors you’ll see when the bold attribute is enabled. By using these eight base colors, plus their bold variants, you can have up to sixteen custom colors in your scheme. (Again, the bold variants don’t have to match the base color, i.e., BOLD + RED could actually be bright orange if you want.)
Before tweaking dircolors, when I set my terminal background to a beige-ish color, ‘ls --color=auto’ produced this awful mess: Here’s what I wound up with after some minor tweaking:For my money, this is a lot subtler and easier on the eyes. And it’s readable, which seems like a good minimum standard. :-}
The only thing you have to look out for with this setup is that logging in remotely via ssh may cause you to see some funky colors, depending on the type of your remote terminal. You can mitigate this by tweaking your dircolors config so it looks reasonable when logged in remotely, then re-jiggering your gnome-terminal colors to taste. This is where having the ability to use completely different colors in gnome-terminal can help: use something that’s at least legible in a standard xterm, and then map those settings—whatever they are—so they look good in gnome-terminal.
Another option is to make the display of colors conditional on whether SSH_CLIENT is defined:
if [ -z $SSH_CLIENT ]; then
alias ls='ls -hF --color=auto'
else
alias ls='ls -hF'
fi
This is often the sanest choice. Alternatively, you can conditionally source a different dircolors config:
if [ –z $SSH_CLIENT ]; then
# Local login: use default settings
eval $(dircolors -b ~/.dircolors)
else
# Remote login: use alternate color scheme
eval $(dircolors -b ~/.dircolors_remote)
fi
But this starts getting into the realm of diminishing returns, IMO. I usually find it easier to create a profile with a custom color-mapping on the SSH client. If it’s a Windows machine, PuTTY can be used for this; if it’s another Linux box, then gnome-terminal (or konsole/whatever) can be used in the same way described above.
As an example, here’s how my current color scheme looks using a default PuTTY session: This looks okay-ish, but if I were going to be logging in remotely a lot, I might create a custom config in PuTTY whose colors exactly match the gnome-terminal settings on the host. Here’s what I get when I do that:You can see that these muted colors more-or-less match those of the gnome-terminal screenshot above. (It looks a little different because there’s no transparency, but it’s close.)
Having different color schemes for different hosts (or different types of hosts) can really help you stay oriented when working with multiple machines. You can know immediately, for example, that any terminal with a green background is connected to the Sound Server, and any terminal with a beige background is connected to the Simulation Host and any terminal with a black background is connected to an Image Generator. (Or whatever server types are appropriate for the app sphere you work in.)
Once you’ve worked with a color scheme like this for awhile, you find it hard to go back to an undifferentiated mess of bland terminals, which is why I find myself doing a lot of color-wrangling when setting up a new system. Hopefully this Note To Self will make that process a bit easier…
terminal bash 颜色的详细解释的更多相关文章
- tar命令的详细解释
tar命令的详细解释 标签: linuxfileoutputbashinputshell 2010-05-04 12:11 235881人阅读 评论(12) 收藏 举报 分类: linux/unix ...
- 用python进行OpenCV实战之用OpenCV3实现图片载入、显示和储存(argparse详细解释)
将下面文档存为load_display_save.py #-*- coding:utf-8 -*- ap = argparse.ArgumentParser() ap.add_argument(&qu ...
- Linux下函数调用堆栈帧的详细解释【转】
转自:http://blog.chinaunix.net/uid-30339363-id-5116170.html 原文地址:Linux下函数调用堆栈帧的详细解释 作者:cssjtuer http:/ ...
- in文件注意事项及详细解释
lammps做分子动力学模拟时,需要一个输入文件(input script),也就是in文件,以及关于体系的原子坐标之类的信息文件(data file)和势文件(potential file).lam ...
- 每天进步一点点------YUV格式详细解释
YUV格式详细解释 YUV开放分类: 网络.计算机.手机.色彩学.影像学 概述 YUV(亦称YCrCb)是被欧洲电视系统所采用的一种颜色编码方法(属于PAL),是PAL和SECAM模拟彩色电视制式 ...
- in文件注意事项及详细解释(转载)
转载自:https://www.cnblogs.com/sysu/p/10817315.html 和 https://www.cnblogs.com/panscience/p/4953940.h ...
- .htaccess语法之RewriteCond与RewriteRule指令格式详细解释
htaccess语法之RewriteCond与RewriteRule指令格式详细解释 (2012-11-09 18:09:08) 转载▼ 标签: htaccess it 分类: 网络 上文htacc ...
- cookie的详细解释
突然看到网页上中英文切换的效果,不明白怎么弄得查了查 查到了cookie 并且附有详细解释 就copy留作 以后温习 http://blog.csdn.net/xidor/article/detail ...
- Linux学习笔记15——GDB 命令详细解释【转】
GDB 命令详细解释 Linux中包含有一个很有用的调试工具--gdb(GNU Debuger),它可以用来调试C和C++程序,功能不亚于Windows下的许多图形界面的调试工具. 和所有常用的调试工 ...
随机推荐
- Codeforces 55D Beautiful Number
Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...
- 【IT历史】SP和CP
1.什么是SP?SP是英文Service Provider的缩写,中文翻译为服务提供商,通常是指在移动网内运营增值业务的社会合作单位.它们建立与移动网络建立相连的服务平台,为手机用户提供一系列信息服务 ...
- 【GPS】 数据围栏
1.记录gps信息,定位类型 gps agps ,偏移量 2.根据id检索用户 gps 历史记录 3.创建围栏 4.围栏内用户检索(先实现 圆形和矩形) 5.判断一个点是否进出围栏 应用场景: o ...
- Spring核心框架 - AOP的起源及介绍
一.AOP技术起源 AOP技术的诞生并不算晚,早在1990年开始,来自Xerox Palo Alto Research Lab(即PARC)的研究人员就对面向对象思想的局限性进行了分析.他们研究出了一 ...
- loadrunner_analysis技巧_average 和 90% percent
“90% Percent Time” 表示90%的事务response time 都维持在某个值附近,不是 average response time * 90%; “Average Time” 平 ...
- ANDROID_MARS学习笔记_S01原始版_020_Mp3player001_歌曲列表
一.项目设计 二.歌曲列表简介 1.利用java.net.HttpURLConnection以流的形式下载xml文件为String 2.自定义ContentHandler-->Mp3ListCo ...
- 校园网之MentoHUST安装与使用
作用:MentoHUST可以解决校园网锐捷客户端与Windows的兼容性问题,可以解决安装虚拟机之后虚拟机网卡与本地网卡冲突的问题,可以做到愉快的用校园网,并可以愉快的用校园网开Wifi给自己或者小伙 ...
- bzoj2756
看到相邻格子都+1的操作一下就想到黑白染色了相邻格子都+1说明不管怎么弄,黑格子的总和和白格子总和的差总是定值这里首先要注意,最后不一定变成的是所有元素中的最大值,可能比它大比如 1 2 2 ...
- Memcached‘do_item_get’函数安全漏洞
漏洞名称: Memcached‘do_item_get’函数安全漏洞 CNNVD编号: CNNVD-201401-175 发布时间: 2014-01-15 更新时间: 2014-01-15 危害等级: ...
- Memcached‘process_bin_delete’函数安全漏洞
漏洞名称: Memcached‘process_bin_delete’函数安全漏洞 CNNVD编号: CNNVD-201401-174 发布时间: 2014-01-15 更新时间: 2014-01-1 ...