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下的许多图形界面的调试工具. 和所有常用的调试工 ...
随机推荐
- Python创建list
Python内置的一种数据类型是列表:list.list是一种有序的集合,可以随时添加和删除其中的元素. 比如,列出班里所有同学的名字,就可以用一个list表示: >>> ['Mic ...
- 深入WSGI,并按样例实现一个
感觉WSGI确实和SERVLET相似,为PYTHON提供了运行和管理环境.WSGI服务器和PYTHON的WEB框架一起,实现WEB响应. 步骤: 首先,服务器启动并加载一个由Web框架/应用提供的可调 ...
- 【NOIP 2015 DAY2 T3】 运输计划 (树链剖分-LCA)
题目背景 公元 2044 年,人类进入了宇宙纪元. 题目描述 L 国有 n 个星球,还有 n-1 条双向航道,每条航道建立在两个星球之间,这 n-1 条航道连通了 L 国的所有星球. 小 P 掌管一家 ...
- http://www.itpub.net/thread-1778530-1-1.html
http://www.itpub.net/thread-1778530-1-1.html
- UVA 10896 Sending Email
这个题目真是伤透脑筋了,一直RE,连着改了好几个版本,又是spfa,又是单调队列dijkstra+单调队列,总是不过,后来发现M开小了,双向边应该开m的两倍,悲剧啊!!!以后不管怎样,数组一定要尽量开 ...
- [topcoder]BusinessTasks
水题,不值一提.http://community.topcoder.com/stat?c=problem_statement&pm=1585&rd=6535 import java.u ...
- ANDROID_MARS学习笔记_S01原始版_007_Handler及线程的简单使用
一.运行结果 一.代码1.xml(1)activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.c ...
- VC++下封装ADO类以及使用方法
操作系统:windows 7软件环境:visual studio 2008 .Microsoft SQL 2005本次目的:介绍一个已经封装的ADO类,简单说明怎么导入使用 首先声明一下,这个封装的A ...
- QT做界面真是绝美,并且还可嵌入HTML与JS做界面(许多案例)
1. 这年头想要酷炫, 还是用web最方便, QT自带嵌入式webkit, 然后用d3.js D3.js - Data-Driven Documents什么的, 各种酷炫的互动表随手而来.这里有各种各 ...
- HTML <!--...--> 注释标签
HTML <!--...--> 注释标签 实例 HTML 注释: <!--这是一个注释,注释在浏览器中不会显示--> <p>这是一个段落</p> 浏 ...