一、提示符分解

默认提示符如下所示:

 [me@linuxbox ~]$

可以看出它包括我们的用户名、主机名、当前工作目录。提示符是由PS1变量定义的。

 [me@linuxbox ~]$ echo $PS1
[\u@\h \W]\$


二、尝试设计提示符

先存储一下原来的提示符:

 [me@linuxbox ~]$ ps1_old="$PS1"

查看一下

 [me@linuxbox ~]$ echo $ps1_old
[\u@\h \W]\$

先设置一个空的提示符:

 [me@linuxbox ~]$ PS1=

提示符仍然在那儿,但是什么都不显示。

 PS1="\$ "


三、尝试给提示符添加颜色

 <me@linuxbox ~>$ PS1="\[\033[0;31m\]<\u@\h \W>\$ "
<me@linuxbox ~>$

同样背景颜色也可以设置:


保存设置

 PS1="\[\033[s\033[0;0H\033[0;41m\033[K\033[1;33m\t\033[0m\033[u\]
<\u@\h \W>\$ "
export PS1

我们可以将提示符添加到.bashrc文件中。

The linux command 之定制提示符的更多相关文章

  1. 《The Linux Command Line》 读书笔记01 基本命令介绍

    <The Linux Command Line> 读书笔记01 基本命令介绍 1. What is the Shell? The Shell is a program that takes ...

  2. 《The Linux Command Line》 读书笔记04 Linux用户以及权限相关命令

    Linux用户以及权限相关命令 查看身份 id:Display user identity. 这个命令的输出会显示uid,gid和用户所属的组. uid即user ID,这是账户创建时被赋予的. gi ...

  3. 《The Linux Command Line》 读书笔记02 关于命令的命令

    <The Linux Command Line> 读书笔记02 关于命令的命令 命令的四种类型 type type—Indicate how a command name is inter ...

  4. Linux Command Line Basics

    Most of this note comes from the Beginning the Linux Command Line, Second Edition by Sander van Vugt ...

  5. Linux Command Line 解析

    Linux Command Line 解析 0 处理模型 Linux kernel的启动包括很多组件的初始化和相关配置,这些配置参数一般是通过command line进行配置的.在进行后续分析之前,先 ...

  6. 15 Examples To Master Linux Command Line History

    When you are using Linux command line frequently, using the history effectively can be a major produ ...

  7. 10 Interesting Linux Command Line Tricks and Tips Worth Knowing

    I passionately enjoy working with commands as they offer more control over a Linux system than GUIs( ...

  8. Reso | The Linux Command Line 的中文版

    http://book.haoduoshipin.com/tlcl/book/zh/ 本书是 The Linux Command Line 的中文版, 为大家提供了多种不同的阅读方式. 中英文双语版- ...

  9. [笔记]The Linux command line

    Notes on The Linux Command Line (by W. E. Shotts Jr.) edited by Gopher 感觉博客园是不是搞了什么CSS在里头--在博客园显示效果挺 ...

随机推荐

  1. upc组队赛2 Master of GCD 【线段树区间更新 || 差分】

    Master of GCD 题目描述 Hakase has n numbers in a line. At fi rst, they are all equal to 1. Besides, Haka ...

  2. flex 布局,flex-grow 宽度未等比放大问题解决办法

    本文转载自:https://blog.csdn.net/sinat_41695090/article/details/79215893 先粘贴上一段代码,flex总体布局 <body> & ...

  3. 第八篇 编写spider爬取jobbole的所有文章

    通过scrapy的Request和parse,我们能很容易的爬取所有列表页的文章信息. PS:parse.urljoin(response.url,post_url)的方法有个好处,如果post_ur ...

  4. mongo之$rename更新一个字段的名称(可批量)

    $rename操作逻辑执行$unset 老名称和新的名称,然后执行 $set新名称运行.因此,操作可能不保留文档中字段的顺序; 即重命名的字段可以在文档内移动. 1.重命名字段:一级字段 格式: db ...

  5. 【转】移动前端开发之viewport的深入理解

    原文链接:https://blog.csdn.net/u012402190/article/details/70172371 笔记 (20180919,目前暂且只看一部分)

  6. 使用JMeter进行http压力测试

    一.背景及文档目的说明 采用JMeter测试工具对腾讯视频做负载测试,使用 JMeter图形结果和聚合图帮助测试系统在资源超负荷情况下的表现,以发现设计上的错误或验证系统的负载能力并估计系统瓶颈和并发 ...

  7. win10无法设置移动热点的一种解决办法

    我的笔记本网卡为:Intel(R) Centrino(R) Wireless-N 2230 最近发现win10自带的移动热点无法启动了,一直显示无法设置热点 参考网上的教程,例如http://jing ...

  8. JS window对象 取消计时器clearTimeout() setTimeout()和clearTimeout()一起使用,停止计时器。 语法: clearTimeout(id_of_setT

    取消计时器clearTimeout() setTimeout()和clearTimeout()一起使用,停止计时器. 语法: clearTimeout(id_of_setTimeout) 参数说明: ...

  9. 类 __init__的注意事项

    class Dog():  class类 后面的ClassName类名第一个字母一定要大写. def __init__(self,name,age):    注意init前后是英文格式下,前后都是两道 ...

  10. Replication Controller、Replica Set

    假如我们现在有一个Pod正在提供线上的服务,我们来想想一下我们可能会遇到的一些场景: 某次运营活动非常成功,网站访问量突然暴增 运行当前Pod的节点发生故障了,Pod不能正常提供服务了 第一种情况,可 ...