- 浏览: 599570 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
oldrat:
还给出了 给出“对于多条A记录是采用什么策略返回IP”的结论, ...
【转载】关于java dns cache (域名缓存时间) -
snowing0427:
特地登录来感谢一下楼主~!!!
nginx里的break和last -
夏日小草:
403禁止了。
User Agent信息大全 -
uag:
比如从请求头里的$HOST变量里获取。(针对nginx,需要加 ...
nginx替换apache中的一个跳转问题 -
thinktothings:
修改Makefile文件 在哪,怎么修改?
使用sz,rz命令来上传和下载文件
在linux下可以自定义自己的颜色方案,不管是linux命令提示符的颜色,还是stdout的输出颜色。
在 /etc/DIR_COLORS 下可以找到如下说明:
[root@CentOS ~] #cat /etc/DIR_COLORS # Below are the color init strings for the basic file types. A color init # string consists of one or more of the following numeric codes: # Attribute codes: # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed # Text color codes: # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white # Background color codes: # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white NORMAL 00 # global default, although everything should be something. FILE 00 # normal file DIR 01;34 # directory LINK 01;36 # symbolic link FIFO 40;33 # pipe SOCK 01;35 # socket BLK 40;33;01 # block device driver CHR 40;33;01 # character device driver ORPHAN 01;05;37;41 # orphaned syminks MISSING 01;05;37;41 # ... and the files they point to
--最重要的部分在这里:
# Attribute codes: # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed # Text color codes: # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white # Background color codes: # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
下面 举两个例子:
1、让输出的字符带上颜色
定义一个脚本:
#!/bin/bash # 先定义一些颜色: red='\e[0;31m' # 红色 RED='\e[1;31m' # 红色+粗体(后面以此类推) green='\e[0;32m' # 绿色 GREEN='\e[1;32m' yellow='\e[0;33m' # 黄色 YELLOW='\e[1;33m' blue='\e[0;34m' # 蓝色 BLUE='\e[1;34m' purple='\e[0;35m' # 紫色 PURPLE='\e[1;35m' cyan='\e[0;36m' # 蓝绿色 CYAN='\e[1;36m' WHITE='\e[1;37m' # 白色 NC='\e[0m' # 没有颜色 echo -e "${CYAN}This is BASH ${RED}${BASH_VERSION%.*}${CYAN} - DISPLAY on ${RED}$DISPLAY${NC}\n" echo -e "${RED}RED ${BLUE}BLUE ${cyan}cyan ${GREEN}GREEN${NC}" echo -e "${CYAN}white ${WHITE}blod white ${NC} no color!!" echo "${CYAN}white ${WHITE}blod white ${NC} no color!!" #注意这句
运行结果如下:
注:这里要加上 -e 参数才能正确输出颜色。
( -e 的解释:-e enable interpretation of backslash escapes | 大致意思是允许解释反斜杠)
2、修改命令提示符(也就是:[root@CentOS ~]# )
我们可以给 [root@CentOS ~]# 加上颜色和自定义格式:
修改 /etc/bashrc 来达成我们的目的:
vi /ete/bashrc,跟上面一样,大概修改成下面的样子(颜色可以自己换)
red='\e[0;31m' # 红色 cyan='\e[0;36m' # 蓝绿色 NC='\e[0m' # 没有颜色 # [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[${red}\u${NC}@${cyan}\h${NC} \W]\\$ "
然后保存退出,重新登录终端,输出结果如下:
颜色已经改变,不在是默认的全白色啦~
关于命令提示符的格式,请参考这个:
\a : an ASCII bell character (07) \d : the date in "Weekday Month Date" format (e.g., "Tue May 26") \D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required \e : an ASCII escape character (033) \h : the hostname up to the first '.' \H : the hostname \j : the number of jobs currently managed by the shell \l : the basename of the shell’s terminal device name \n : newline \r : carriage return \s : the name of the shell, the basename of $0 (the portion following the final slash) \t : the current time in 24-hour HH:MM:SS format \T : the current time in 12-hour HH:MM:SS format \@ : the current time in 12-hour am/pm format \A : the current time in 24-hour HH:MM format \u : the username of the current user \v : the version of bash (e.g., 2.00) \V : the release of bash, version + patch level (e.g., 2.00.0) \w : the current working directory, with $HOME abbreviated with a tilde \W : the basename of the current working directory, with $HOME abbreviated with a tilde \! : the history number of this command \# : the command number of this command \$ : if the effective UID is 0, a #, otherwise a $ \nnn : the character corresponding to the octal number nnn \\ : a backslash \[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt \] : end a sequence of non-printing characters
最好的办法就是一次全部打印出来试试,嘿嘿。
---------------------------------------------------------华丽的结束符------------------------------------------------
希望对你也有所帮助,that's all……
发表评论
-
ntp的客户端配置
2013-02-25 19:42 0——背景简介: ... -
installing goagent on ubuntu(12.04 LTS)
2012-12-14 23:39 4409If you want to access some bloc ... -
Fedora17-command not found-命令延时
2012-11-13 14:35 1336Fedora 17下不小心输入错误一条命令,提示command ... -
can't identify protocol问题的定位和解决
2012-10-08 19:08 13443在观摩了一个关于性能问题排查的PPT之后试着用lsof命令来列 ... -
【转载】Linux日志管理:实例详解syslog
2012-09-29 16:40 2946=============================== ... -
使用nfs挂载远端主机目录到本地
2012-09-06 00:18 3188由于一个应用的需要,要使用这方面的知识。 就是两台机器,1 ... -
fedora 17继续折腾
2012-08-22 13:37 1608今天来折腾fedora17了…… 安装的64位: ... -
再谈yum配置
2012-08-18 15:13 1069配置环境永远是最重要的第一步。 在我又开始折腾虚拟机的 ... -
一个简单的监控后台需要什么?
2012-08-07 23:55 1822今晚突然想到要给之前学校的一个网站做一个监控的后台, 一些常 ... -
yum源的配置以及一个错误解决
2012-07-30 15:16 2328今天刚拿到一台新机器,系统为Red Hat Enterpris ... -
SSH建立信任关系实现免输密码登陆
2012-07-18 19:09 3824为了方便管理,在需要频繁登陆机器,特别是在机器众多的时候,免密 ... -
epoll介绍【转】
2012-07-17 16:55 2017epoll是多路复用IO(I/O Multiplexing) ... -
关于代理和反向代理
2012-07-12 16:10 1144其实简单来讲,代理和反向代理可以这么来理解: 代理: ... -
RHEL-AS4安装yum
2012-05-11 02:15 3649我的系统版本: Red Hat Enterprise Lin ... -
Ubuntu8.04安装CP-168U的串口连接问题
2012-05-05 18:26 2275毕业设计需要用到1托8的MOXA CP-168U卡做一个交换机 ... -
制作用U盘引导安装Ubuntu12.04
2012-05-02 14:04 38702由于之前刻了两次碟,均在安装完一次系统之后就损坏了。。。 所 ... -
【转载】su和sudo命令的区别与使用技巧
2012-04-12 23:21 1524一. 使用 su 命令临时切换用户身份 1、su ... -
Linux内核学习步骤
2011-11-25 10:33 2593今日在论坛中看到大牛谈如何学习Linux内核,于是摘录的 ... -
【转】什么是Linux的僵尸(zombie)进程
2011-10-08 15:55 2065可能很少 ... -
取得jboss的版本信息
2011-09-26 20:44 14240由于写脚本的需要, 要获取jboss的版本信息。 大 ...
相关推荐
适用于Javascript开发的VIM颜色方案
SecureCRT v8.x高亮配色方案,适用于linux 查看使用链接地址:https://blog.csdn.net/qq_39184753/article/details/113496206
基于Material Theme Darker的黑暗vim色彩方案, 针对Web开发改进。
本书详细介绍如何在个人电脑上安装配置Caldera和Red Hat两种发行版本的Linux操作系统,并能帮助用户解决安装和配置过程中出现的各种问题。本书既能指导你进行基本的安装步骤,也能指导你定制独具特色的Linux 操作...
Linux java程序加水印时中文乱码解决方案
Sacred Forest: 用于vim文本编辑器的深色低对比度半最小色彩方案
Swatch是一个Vim 插件,可以更轻松地使用十六进制颜色代码和配色方案
《星夜》的灵感来自我从梵高(Van Gogh)在原本应该是深色的调色板上使用鲜艳的色彩时所产生的情感,以及base16-eighties.vim配色方案中的一些美丽色彩。 配色方案本身是使用Colortemplate插件创建的。 此配色方案...
本书详细介绍如何在个人电脑上安装配置Caldera和Red Hat两种发行版本的Linux操作系统,并能帮助用户解决安装和配置过程中出现的各种问题。本书既能指导你进行基本的安装步骤,也能指导你定制独具特色的Linux 操作...
嵌入式linux操作系统的快速发展,迫切需求一种简洁的人机交互界面,为此,本文介绍了如何在FrameBuffer基础上设计自己的嵌入式GUI的简单方法。 1 显示原理 1.1 颜色表示 颜色是所有绘图操作的基础。16位的...
colorscheme evening 切换颜色方案 set ignorecase 忽略大小写搜索 set hlsearch 在关键词上按*,自动高亮 set incsearch 搜索时输入一个字符会自动跳到匹配位置,按回车再确定是否要搜索此关键词 set ...
Vim是我们在Linux中非常常用的一款文本编辑器。Vim 是一款免费、开源的文本编辑器,它的功能和许多其他的文本编辑器大致相同,比如 Sublime 和 Notepad++ 。Vim既可以在命令行中执行,也可以在图形界面中操作。 Vim ...
企业网站项目设计方案计划书 一、企业建设网站前的市场分析 ...以上为网站规划书中应该体现的主要内容,根据不同的需求和建站目的,内容也会在增加或减少。在建设网站之初一定要进行细致的规划,才能达到预期建站目的。
目前在使用的一种配色方案,只要将该文件复制到VSCode的主体文件目录中($RELEASE/resources/app/extensions),以theme-开头的目录即为颜色主题配置 打开vscode,按键选择ctrl+k,ctrl+t,选择Monokai-My即可切换...
:water_wave:material.nvim用lua主题编写的NeoVim的端口或材质颜色方案受https://github.com/kaicataldo/material.vim的启发。受https://github.com/kaicataldo/material.vim启发:trident_emblem:信息这是不再依赖...
通过个性化配置和插件系统,用户可以定制快捷键、颜色方案等。Vim 还可以作为图形化编辑器,在不同操作系统上运行,并与版本控制系统集成。总之,Vim 是一款高效、灵活的编辑器,为用户提供优秀的编辑体验。 0x00 ...
深色版本浅色版本灵感在通向该配色方案的过程中发生了很多巧合。 摘要,按时间顺序排列; 我亲爱的朋友mengu发了一条推文,并提到如果有人用这些颜色制作一个颜色主题,他会很乐意使用它。 那些时候我在尝试Emacs...
Kicad颜色方案是否要更改KiCad的配色方案? 在这里寻找灵感。如何使用颜色主题。 每个主题目录都包含在您的个人资料中找到的eschema和pcbnew设置文件的颜色定义部分。 对于〜.config / kicad /下Linux Windows XP:...
作为自己极为方便和顺手的编译器,在最近两年的使用中,我不断的更新和加强vim的功能,特此备份。。。 ============================== 开启最大化 (win32用户直接就可以最大化,但是linux用户则需要安装wmctrl,...
对Linux用户有用的脚本 ... 根据颜色方案配置BG和FG变量 用法 ➤ wa helsinki to dublin plane 2 hours 20 minutes ➤ wa time in dublin 5:37:57 pm GMT; Friday, January 27, 2017 ➤ wa 15.36 engli