一、提示符分解

默认提示符如下所示:

 [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. 剑指offer——69队列的最大值

    题目: 队列的最大值.请定义一个队列并实现函数max得到队列里的最大值,要求函数max.push_back和pop_front的时间复杂度都是O(1). 题解: 使用队列,操持队列的排序为从大到小的顺 ...

  2. Guava Spiltter类

    Splitter 提供了各种方法来处理分割操作字符串,对象等. 类声明 以下是com.google.common.base.Splitter类的声明: @GwtCompatible(emulated= ...

  3. Django(十四)课程机构列表页数据展示,Django的modelform,关于urls的重新分发

    关于urls的重新分发: 如果所有url都配置在根路径的urls.py里,会特别多,而且也不易于修改,Django框架里支持urls的重新分发: 1.在根路径的urls配置上: PS:namespac ...

  4. POJ 3259 Wormholes Bellman题解

    版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/.未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...

  5. extend java vm memory parameter in pom.xml

    <project> [...] <build> [...] <plugins> <plugin> <groupId>org.apache.m ...

  6. jdk源码阅读-ConcurrentLinkedQueue(一)

    说明 concurrentLinkedQueue为无界非阻塞队列,是线程安全的 内部结构为链表的形式, 内部使用cas保存线程安全.采用cas保证原子性 什么是CAS CAS 操作包含三个操作数 —— ...

  7. QT开发资料

    QT开发入门资料 https://tmr.js.org/p/cc37608/ QT学习之路: https://www.devbean.net/

  8. line-height 行高的使用

    line-height:normal; 默认  字体 line-height:1.5; line-height:200%; line-height:50px;  ps : 固定的值 line-heig ...

  9. composer(作曲家)安装php-ml

    刚开始我用的是up5.6版本php命令安装composer 后来使用composer时发现命令行会提示php版本太低 于是我下载了wamp,使用7.1版本的php重新安装了composer,因为php ...

  10. bzoj1040题解

    [题意分析] 给你一个带权基环树森林,求它的点集的无邻点子集的最大权值和. [解题思路] 对于树的部分,做一遍拓扑排序+递推即可(f[i][j]表示第i个节点选取状态为j(0/1)可以得到的最大权值和 ...