customize shell prompt
想必在命令行模式用久了,都看厌了那个单调又丑的提示符,个人认为还占了些位,要是命令长的话还会断行.
想改成
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相关推荐
- Shell 十三问 的学习记录
在 BBS上看到了Shell十三问的帖子,由于比较就远了,怕以后再也找不到了,就把笔记贴过来了, 原帖地址: shell 十三问 http://bbs.chinaunix.net/thread-203 ...
- Shell脚本十三问
1. 为何叫做 Shell? 我们知道计算机的运作离不开硬件,但却无法直接操作硬件,硬件的驱动只能通过一种称之为"操作系统(OS,Opertating System)的软件来管控.Linux ...
- SHELL基础学习必杀技之十三问
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 原创 Chin ...
- python获取耗时的shell_python获取耗时的shell_关于Linux:在shell中获取程序执行时间...
我想在Linux shell中在几个不同的条件下执行一些东西,并且能够输出每次执行的执行时间. 我知道我可以编写一个Perl或python脚本来完成这个任务,但是有没有一种方法可以在shell中完成呢 ...
- Linux Shell 通配符、元字符、转义符使用实例介绍
说到shell通配符(wildcard),大家在使用时候会经常用到.下面是一个实例: ? 1 ? 1 2 3 4 [chengmo@localhost ~/shell]$ ls a.txt b.tx ...
- JSch:纯JAVA实现远程执行SSH2主机的SHELL命令
http://txy821.iteye.com/blog/1405230 http://my.oschina.net/hetiangui/blog/137426 上篇文章我编写了利用JSch实现SFT ...
- python与shell的3种交互方式介绍
[目录] 1.os.system(cmd) 2.os.popen(cmd) 3.利用subprocess模块 4.subprocessor模块进阶 [概述] 考虑这样一个问题,有hello.py脚本, ...
- 原版英文书籍《Linux命令行》阅读记录1 | 什么是shell?
背景: 阅读英文原作只为了更好地理解书中的精髓,当然也是为了更好地掌握书中的技巧.我们会坚持阅读全书,并记录书中的精髓. 1. 理解 Linux 的 "自由" Many peopl ...
- shell菜鸟学习之echo命令
echo是一个非常简单.直接的LINUX命令. 稍等........ 先介绍一下标准的command line ,它包含三个部件: command_name option argument 好的,回来 ...
最新文章
- JSONP实现Ajax跨域请求
- 【NLP】使用Python可视化Word2vec的结果
- js动态添加options(转载)
- 记一次.net mvc中 RouteAttribute 不起作用
- mockwebserver java_在Java中使用WireMock和SOAP Web服务
- 详细解读八大无线网络安全技术利弊
- CodeForces - 1612A Distance
- UNIX系统编程小结(三)----进程相关
- [轉]PHP执行MYSQL存储过程报错:Commands out of sync; you can't run this command now 问题的解决...
- day02.2-常用Linux命令整理
- ubuntu下安装配置java8
- 制作基于WiFi局域网的自动开门装置2.0(Arduino+微信小程序)
- Arangodb Basic CRUD
- 计算机管理模块无法初始化单元,win7组策略提示MMC无法初始化管理单元怎么办...
- qt远程调试ARM板
- MFC 隐藏/显示鼠标图标
- SQL 登录注入脚本_vBulletin再修复高危RCE和SQL注入漏洞
- android 相机编程,Android相机开发系列
- vue中插值语法中v-for() of 与v-for() in 遍历对象数组的异同,以及for in for of在方法中遍历对象和数组的异同
- PHP项目开发案例全程实录pdf