想必在命令行模式用久了,都看厌了那个单调又丑的提示符,个人认为还占了些位,要是命令长的话还会断行.

想改成

cd ~/
touch.bash_profile
vim .bash_profile

osx环境下操作的,关键语法 \[颜色\]prompt参数\[$reset\] 例如:\[$red\]\t\[$reset\]

reset=$(tput sgr0)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
magenta=$(tput setaf 5)
cyan=$(tput setaf 6)PS1="\[$magenta\]\u\[$reset\] at \[$blue\]\h\[$reset\] in \[$yellow\]\W\n\[$reset\]\[$green\]\$\[$reset\]"export PS1

:wq 保存离开

source .bash_profile

tput命令使用方式

prompt参数:

  • \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
  • \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

文章参考,文章参考2

转载于:https://www.cnblogs.com/jHenry/p/4263450.html

customize shell prompt相关推荐

  1. Shell 十三问 的学习记录

    在 BBS上看到了Shell十三问的帖子,由于比较就远了,怕以后再也找不到了,就把笔记贴过来了, 原帖地址: shell 十三问 http://bbs.chinaunix.net/thread-203 ...

  2. Shell脚本十三问

    1. 为何叫做 Shell? 我们知道计算机的运作离不开硬件,但却无法直接操作硬件,硬件的驱动只能通过一种称之为"操作系统(OS,Opertating System)的软件来管控.Linux ...

  3. SHELL基础学习必杀技之十三问

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 原创 Chin ...

  4. python获取耗时的shell_python获取耗时的shell_关于Linux:在shell中获取程序执行时间...

    我想在Linux shell中在几个不同的条件下执行一些东西,并且能够输出每次执行的执行时间. 我知道我可以编写一个Perl或python脚本来完成这个任务,但是有没有一种方法可以在shell中完成呢 ...

  5. Linux Shell 通配符、元字符、转义符使用实例介绍

    说到shell通配符(wildcard),大家在使用时候会经常用到.下面是一个实例: ? 1 ? 1 2 3 4 [chengmo@localhost ~/shell]$ ls a.txt  b.tx ...

  6. JSch:纯JAVA实现远程执行SSH2主机的SHELL命令

    http://txy821.iteye.com/blog/1405230 http://my.oschina.net/hetiangui/blog/137426 上篇文章我编写了利用JSch实现SFT ...

  7. python与shell的3种交互方式介绍

    [目录] 1.os.system(cmd) 2.os.popen(cmd) 3.利用subprocess模块 4.subprocessor模块进阶 [概述] 考虑这样一个问题,有hello.py脚本, ...

  8. 原版英文书籍《Linux命令行》阅读记录1 | 什么是shell?

    背景: 阅读英文原作只为了更好地理解书中的精髓,当然也是为了更好地掌握书中的技巧.我们会坚持阅读全书,并记录书中的精髓. 1. 理解 Linux 的 "自由" Many peopl ...

  9. shell菜鸟学习之echo命令

    echo是一个非常简单.直接的LINUX命令. 稍等........ 先介绍一下标准的command line ,它包含三个部件: command_name option argument 好的,回来 ...

最新文章

  1. JSONP实现Ajax跨域请求
  2. 【NLP】使用Python可视化Word2vec的结果
  3. js动态添加options(转载)
  4. 记一次.net mvc中 RouteAttribute 不起作用
  5. mockwebserver java_在Java中使用WireMock和SOAP Web服务
  6. 详细解读八大无线网络安全技术利弊
  7. CodeForces - 1612A Distance
  8. UNIX系统编程小结(三)----进程相关
  9. [轉]PHP执行MYSQL存储过程报错:Commands out of sync; you can't run this command now 问题的解决...
  10. day02.2-常用Linux命令整理
  11. ubuntu下安装配置java8
  12. 制作基于WiFi局域网的自动开门装置2.0(Arduino+微信小程序)
  13. Arangodb Basic CRUD
  14. 计算机管理模块无法初始化单元,win7组策略提示MMC无法初始化管理单元怎么办...
  15. qt远程调试ARM板
  16. MFC 隐藏/显示鼠标图标
  17. SQL 登录注入脚本_vBulletin再修复高危RCE和SQL注入漏洞
  18. android 相机编程,Android相机开发系列
  19. vue中插值语法中v-for() of 与v-for() in 遍历对象数组的异同,以及for in for of在方法中遍历对象和数组的异同
  20. PHP项目开发案例全程实录pdf

热门文章

  1. 比原链Bytom错误码一览
  2. html基础1-基本语法/段落标签/特殊符号
  3. 10进制颜色 转换成 16进制
  4. ICMP Internet控制报文协议(四)
  5. Dos批处理中符号作用大全
  6. 阿里正式取消周报:打击低效加班,拒绝形式主义!
  7. 扫盲!Java可变长数组,看这篇就对了!
  8. 面试前必须要知道的Redis面试题
  9. GO select用法详解
  10. React Router 使用教程