控制shell终端提示符格式和颜色
|
字体颜色值 (ASCII) |
背景颜色值 (ASCII) |
显示颜色 |
| 30 | 40 | 黑色 |
| 31 | 41 | 红色 |
| 32 | 42 | 绿色 |
| 33 | 43 | 黄色 |
| 34 | 44 | 蓝色 |
| 35 | 45 | 紫红色 |
| 36 | 46 | 青蓝色 |
| 37 | 47 | 白色 |
| 符 号值 | 特效 | 取反 |
| 0 | OFF | |
| 1 | HighLight | |
| 2 | 半亮 | 22 |
| 4 | UndeLine | 24 |
| 5 | Blink | 25 |
| 7 | 反白 | 27 |
| 8 | 不可见 |
注:若着色不对,哈哈,请认为我是色盲吧。
特殊字符着色规则:
着色开始 着色结束
\[\e[*m\] \e[0m
若使用背景颜色或特效需要用;分割成*;*格式 ,"*"代表表中数值(其值见上两表);
如:(方式一 非永久性)

# .bashrc export PS1="你的设置" # Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi # User specific aliases and functions
特殊字符语法规则:
\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 (uses the value of the PROMPT_DIRTRIM vari-
able)
\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
这是我的 (方式二)
编辑.bashrc文件
$ vim ~/.bashrc
在该文件的
# User specific aliases and functions
下面添加如下内容
c1="\[\e[36m\]"
c2="\e[0m"
c3="\[\e[35m\]"
c4="\[\e[32m\]"
c5="\[\e[30m\]"
c6="\[\e[31m\]"
c7="\[\e[34m\]"
export PS1="$c1[$c2$c5\t$c2$c6@$c2$c3\u$c2 $c4\w$c2$c5]$c2$c7\$$c2 "
为什么选 \w 呢?因为 cd 很方便嘛......
控制shell终端提示符格式和颜色的更多相关文章
- #Linux学习笔记# 自定义shell终端提示符
我使用的Linux发行版是LinuxMint 17.2 Rafaela,默认情况下Terminal中的shell提示包括了用户名.主机名.当前目录(绝对路径)和提示符.这样会导致当进入一个比较深的目录 ...
- Linux学习——自定义shell终端提示符
转自:here 我使用的Linux发行版是LinuxMint 17.2 Rafaela,默认情况下Terminal中的shell提示包括了用户名.主机名.当前目录(绝对路径)和提示符.这样会导致当进入 ...
- 【Linux下自定义Shell终端提示符】
目录 基本转义符 字体颜色 背景颜色 移动光标 @ Linux系统终端提示符的特征由系统环境变量 PS1(Prompt String One)定义. 我们可以通过命令echo $PS1来查看当前设置, ...
- ubuntu系统修改终端提示符及设置颜色高亮
Linux终端大家想必都清楚吧,最近在使用的时候发现在进入到某个文件夹目录比较深的层次后,终端提示的绝对路径很长,这样给人的感觉很不习惯,在这里给大家介绍下如何修改终端的提示,顺便介绍下提示符的颜色: ...
- 自定义shell终端提示符及颜色即修改 PS1文件 (以Centos为例)
Linux修改Shell命令提示符及颜色 1. Linux登录过程中加载配置文件顺序: /etc/profile → /etc/profile.d/*.sh → ~/.bash_profile → ~ ...
- Linux 提示符格式及颜色
# 提示符颜色配置: 颜色 黑 红 绿 黄 青 紫 蓝 白 字体 30 31 32 33 34 35 36 37 背景 40 41 42 43 44 45 ...
- shell bash终端中输出的颜色和格式详解(超详细)
文章目录 1) 格式 1.1 Set 1.2 Reset 2)8/16 Colors 2.1 前景(文字) 2.2 背景 3)88/256颜色 3.1 前景(文字) 3.2 背景色 4)组合属性 5) ...
- Linux终端提示符PS1设置(颜色)
\d :代表日期,格式为weekday month date,例如:"Mon Aug 1"\H :完整的主机名称.例如:我的机器名称为:fc4.linux,则这个名称就是fc4.l ...
- Mac终端命令行提示符格式更改方法
内容提要: 主要是通过~/.bash_profile文件更改环境变量PS1,修改命令行提示符的显示格式,并展示不同颜色. 本文介绍了默认设置的缺陷,以及需要用到的基础知识,最后介绍了更改命令行提示符格 ...
随机推荐
- Java实现 LeetCode 240 搜索二维矩阵 II(二)
240. 搜索二维矩阵 II 编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target.该矩阵具有以下特性: 每行的元素从左到右升序排列. 每列的元素从上到下升序排列. ...
- Java实现 LeetCode 45 跳跃游戏 II(二)
45. 跳跃游戏 II 给定一个非负整数数组,你最初位于数组的第一个位置. 数组中的每个元素代表你在该位置可以跳跃的最大长度. 你的目标是使用最少的跳跃次数到达数组的最后一个位置. 示例: 输入: [ ...
- java实现第九届蓝桥杯整理玩具
整理玩具 小明有一套玩具,一共包含NxM个部件.这些部件摆放在一个包含NxM个小格子的玩具盒中,每个小格子中恰好摆放一个部件. 每一个部件上标记有一个0~9的整数,有可能有多个部件标记相同的整数. 小 ...
- ClickHouse基本操作(一)
常用SQL 创建表 1 2 3 4 5 6 7 CREATE TABLE b6logs( eventDate Date, impid UInt64, uid String, idfa String, ...
- centos7 yum源更新
先进入到yum源文件cd /etc/yum.repo.d/ 1.创建一个repo_bak目录,用于保存系统中原来yum的repo文件. sudo mkdir repo_bak 2.备份yum源文件至 ...
- 【图机器学习】cs224w Lecture 16 - 图神经网络的局限性
目录 Capturing Graph Structure Graph Isomorphism Network Vulnerability to Noise 转自本人:https://blog.csdn ...
- 括号匹配-算法详细题解LeetCode
题目:有效的括号 给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效. 有效字符串需满足: 左括号必须用相同类型的右括号闭合. 左括号必须以正确的顺序闭合. ...
- MySQL数据库字符集和排序规则的四个级别
MySQL数据库字符集和排序规则有四个级别的默认设置:服务器,数据库,表和列. 最初,服务器字符集和排序规则取决于启动mysqld时使用的选项.可以使用 --character-set-server该 ...
- mysql安装过程以及遇到问题的解决方法
因为工作原因,配备了新电脑,需要装mysql,今天给大家分享一下安装的过程以及遇到的问题(在此仅介绍压缩包解压方式的安装) 1.准备mysql的压缩包(我使用的是5.7经典版本) 2.配置环境变量,这 ...
- CSS3如何实现div闪烁效果
效果: Html: <h1 class="blink">花花世界</h1> Css: @keyframes fade { from { opacity: 1 ...