一、提示符分解

默认提示符如下所示:

 [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. CUDA编程入门笔记

    1.线程块(block)是独立执行的,在执行的过程中线程块之间互不干扰,因此它们的执行顺序是随机的 2.同一线程块中的线程可以通过访问共享内存(shared memory)或者通过同步函数__sync ...

  2. Spring Boot Restful WebAPI集成 OAuth2

    系统采用前后端分离的架构,采用OAuth2协议是很自然的事情. 下面开始实战,主要依赖以下两个组件: <dependency> <groupId>org.springframe ...

  3. tzselect - 选择一个时区

    总览 tzselect 描述 tzselect 程序向用户询问当前位置的信息,把时区描述作为结果输出到标准输出.此结果适合作为环境变量 TZ 的值. 所有与用户的交互是通过标准输入和标准错误输出完成的 ...

  4. Tk1上搭建turtlebot环境

    sudo apt-get install ros-indigo-turtlebot ros-indigo-turtlebot-apps ros-indigo-turtlebot-interaction ...

  5. TFS发布的时候出现 ENOENT: no such file or directory, stat 'E:\vsts-agent\_work\r57\a\KingEagle-Mysql-Dev\drop\12917.zip' 解决方案

    出现 ENOENT: no such file or directory, stat 'E:\vsts-agent\_work\r57\a\KingEagle-Mysql-Dev\drop\12917 ...

  6. [翻译]windows下 连接到 bitnami的phpmyadmin

    bitnami 因为安全考虑,只能 localhost 访问 phpmyadmin 为了能通过SSH 隧道访问 phpMyAdmin,你需要一个ssh 客户端.参考文章介绍使用中选择使用 PuTTY, ...

  7. vue 中使用 lazyload 插件 数据更图片不更新 的原因 及解决方案

    在使用lazyload插件的img标签上,加上:key标识即可

  8. spark运行任务报错:Container [...] is running beyond physical memory limits. Current usage: 3.0 GB of 3 GB physical memory used; 5.0 GB of 6.3 GB virtual memory used. Killing container.

    spark版本:1.6.0 scala版本:2.10 报错日志: Application application_1562341921664_2123 failed 2 times due to AM ...

  9. Linux环境相关

    Linux环境相关 CentOS7网络配置静态ip CentOS7查看ip地址:以前是ifconfig,现在变成了 ip addr 当然这是配置好环境最后的结果,刚装好系统时时没有下面的ens33的相 ...

  10. lua之table|模块|包

    一.table table是   Lua的一种数据结构用来帮助我们创建不同的数据类型,如:数字.字典等. Lua table使用关联型数组,你可以用任意类型的值来作数组的索引,但这个值不能是   ni ...