• 控制shell终端提示符格式和颜色


    字体颜色值

    (ASCII)

    背景颜色值

    (ASCII)

    显示颜色
    30 40 黑色
    31 41 红色
    32 42 绿色
    33 43 黄色
    34 44 蓝色
    35 45 紫红色
    36 46 青蓝色
    37 47 白色
    符 号值 特效 取反
    0 OFF  
    1 HighLight  
    2 半亮 22
    4 UndeLine 24
    5 Blink 25
    7 反白 27
    8 不可见  

    注:若着色不对,哈哈,请认为我是色盲吧。

    特殊字符着色规则:

    着色开始    着色结束

     [e[*m]     e[0m

    若使用背景颜色或特效需要;分割成*;*格式"*"代表表中数值(其值见上两表)

    如:(方式一 非永久性)

      


    # .bashrc export PS1="你的设置" # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific aliases and functions

    特殊字符语法规则:

                  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
                  
         newline
                  
         carriage return
                  s     the name of the shell, the basename of  $0  (the  portion
                         following the final slash)
                  	     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 (uses the value of the PROMPT_DIRTRIM vari-
                         able)
                  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 $
                  
    nn   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

    这是我的 (方式二)

    编辑.bashrc文件

    $ vim ~/.bashrc

    在该文件的
    # User specific aliases and functions

    下面添加如下内容

    c1="[e[36m]"
    c2="e[0m"
    c3="[e[35m]"
    c4="[e[32m]"
    c5="[e[30m]"
    c6="[e[31m]"
    c7="[e[34m]"
    export PS1="$c1[$c2$c5 $c2$c6@$c2$c3u$c2 $c4w$c2$c5]$c2$c7$$c2 "

    为什么选 w 呢?因为 cd   很方便嘛......

  • 相关阅读:
    python框架---->APScheduler的使用
    python基础---->python的使用(六)
    python爬虫---->scrapy的使用(一)
    python基础---->python的使用(四)
    python基础---->python的使用(一)
    网页mp3播放代码
    js打开没有地址栏下拉条新窗口
    php全面获取url地址栏及各种参数
    php分页类
    php生成随机密码的几种方法
  • 原文地址:https://www.cnblogs.com/wjshan0808/p/3323250.html
Copyright © 2020-2023  润新知