在Linux中,语句中的分号一般用作代码块标识 1.单行语句一般要用到分号来区分代码块,例如: if [ "$PS1" ]; then echo test is ok; fi test is ok 该脚本或命令行中,需要两个分号才为正确的语句,第一个分号是then前的分号,用于标识条件块结束,第二个分号在fi前,用于标识then块结束,如果缺少这两个分号,则程序执行错误. 这里有趣的是echo后的字符串不需要使用引号也能正确地被识别. 注意:语句结尾不要分号. 2.该代码若写作多行,用
编写shell脚本的时候.通过改变shell的显示颜色,不但可以改变使用shell终端的体验,并且更为有用的是,可以通过改变显示内容的颜色来区分正常输出.warning和error等不同关注级别的输出内容. 1.转义序列(Escape sequence) An escape sequence is a series of characters used to change the state of computers and their attached peripheral devices.
function git-branch-name { git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3 } function git-branch-prompt { local branch=`git-branch-name` if [ $branch ]; then printf " [%s]" $branch; fi } PS1="\u@\h \[\033[0;36m\]\W\[\033[0m\