一、提示符分解

默认提示符如下所示:

 [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. 类型转换、类型安全以及is和as的使用

    class Program { static void Main(string[] args) { //1.类型转换 { //隐式转换:不需要转型,因为new返回一个Employee对象,而Objec ...

  2. vim + ctag + Taglist (转)

    一.ctag 当然,第一步就是要下载它!一条命令搞定: $sudo apt-get install ctags 如果不幸提示找不到软件包ctags,首先你也许应该update一下你的软件源,还不行的话 ...

  3. 使用ProxyBroker构建代理池

    import asyncio from proxybroker import Broker async def show(proxies): while True: proxy = await pro ...

  4. c# winForm DotNetBar控件之SuperGridControl

    1.添加表头 sgc.PrimaryGrid.SelectionGranularity = SelectionGranularity.Row;//点击选中一行 DevComponents.DotNet ...

  5. Flask数据库的基本操作

    Flask操作数据库基本操作   常用的SQLAlchemy字段类型 类型名 python中类型 说明 Integer int 普通整数,一般是32位 SmallInteger int 取值范围小的整 ...

  6. thinkphp助手函数

    tp3 C($name=null, $value=null,$default=null) 获取和设置配置参数 支持批量定义 load_config($file,$parse=CONF_PARSE) 加 ...

  7. Bash 脚本 set 命令教程

    http://www.ruanyifeng.com/blog/2017/11/bash-set.html set命令是 Bash 脚本的重要环节,却常常被忽视,导致脚本的安全性和可维护性出问题.本文介 ...

  8. nodejs jade 模板 引擎的使用方法

    1.新建项目 2.使用模板引擎 app.set('view engine','jade'); 3.使用render渲染一个视图 res.render(用于指定需要被渲染的视图(必选),本地变量(可选) ...

  9. CSIC_716_20191127【组合,封装、类的私有属性方法、property装饰器】

    组合 what?   组合是指一个对象中,包含另一个或多个对象. why?      减少代码的冗余. How?     在类中加入其他类的对象,实现跨类对象之间的联动. 耦合度  软件设计要 高内聚 ...

  10. 关于scroll、client、offset和style中的height、width、top以及bottom属性

    内容和图片来自offset.scroll.client三大家族, 此处仅作记录使用 client offset scroll