mac 命令行显示配置

        最近入了个air,试用一下乔老爷子的杰作,犹豫了一阵子才入的,毕竟不便宜,而且关税占17%,一度觉得好亏。。。不过时间应该用来耗费在美好的事物上,不是么?所以咬咬牙还是入了。上手体验确实很爽。超薄的外形,很有质感的金属外壳,酷炫的用户界面,让人激动不已。不过默认的mac命令行界面是黑白的,对于几乎每天都要跟命令行打交到的码农来说,完全黑白的不够赏心悦目。(当然,真正的牛人估计觉得黑白才有质感吧。。)

        打开mac的ls 颜色高亮效果非常简单,只需要在~/.bash_profile中增加下面一行:

export CLICOLOR=1

        如果没有~/.bash_profile文件就自己创建一个就好。

        这样关闭shell后再打开就可以再执行ls命令的时候看到不同的高亮效果了。有的童鞋不满足于系统简单的配色方案,可以到terminal->preferences...中选择自己的配色方案。我暂时用的是系统的方案,看起来比较简洁。以后可以试试其他的方案。

        另外一个配置就是可以自己定制自己的命令行前面的提示信息显示的内容以及格式。用惯的ubuntu之后,感觉不太习惯mac os上的提示,所以搜索了一下相关的文章。

        主要的概念就是系统试用PS环境变量来控制命令行提示符的展示形式。

        其中PS1是主要展示,就是平时我们打开shell的时候显示的那些提示信息。而PS2则是控制副提示标题,一般是需要换行输入的时候显示。

        我的配置很简单:

export PS1="\\u:\\w\\$ "

        用来显示用户名,当前路径,和$符号,另外在最后增加了一个空格用来隔开提示信息和实际用到的命令。

        配置是非常强大的,具体的控制参数如下:

\d – the date in "Weekday Month Date" format (e.g., "Tue May 26")
\e – an ASCII escape character (033)
\h - the hostname up to the first .
\H – the full hostname
\j – the number of jobs currently run in background
\l – the basename of the shells 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., 4.00)
\V – the release of bash, version + patch level (e.g., 4.00.0)
\w – Complete path of current working directory
\W – the basename of the current working directory
\! – 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





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值