zoukankan      html  css  js  c++  java
  • [转]Ubuntu设置Redhat风格的SHELL提示符PS1属性

    默认情况下,Ubuntu终端会输出完整路径,在路径名很长的时候,提示方式很不友好,通过以下步骤修改PS1变量的设置,可以让终端输出相对路径。类似于红帽系统的风格。修改思路:将w修改为W显示绝对路径,并添加[]括号。

    1. 首先修改/etc/bash.bashrc文件
      leo@leo-laptop:~$ sudo vim /etc/bash.bashrc
      修改如下内容:
      #PS1=’${debian_chroot:+($debian_chroot)}u@h:w$ ‘
      PS1=’[${debian_chroot:+($debian_chroot)}u@h:W]$ ‘
    2. 修改/etc/profile文件
      leo@leo-laptop:~$ sudo vim /etc/bash.bashrc
      #PS1=’u@h:w$ ‘
      PS1=’[u@h:W]$ ‘
    3. 最后修改用户目录下的.bashrc文件
      leo@leo-laptop:~$ sudo vim .bashrc
      #PS1=’${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$ ‘
      PS1=’[${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]W[33[00m]]$ ‘#PS1=’${debian_chroot:+($debian_chroot)}u@h:w$ ‘
      PS1=’[${debian_chroot:+($debian_chroot)}u@h:W]$ ‘

    以上内容全部修改完成之后,可以logout重新登录一次,就能看到修改之后的效果了。
    修改之前为
    leo-laptop:/var/lib/tomcat$
    修改之后为
    [leo-laptop:tomcat]$
    相对于直接使用export PS1=”"的方式,此种修改方法保留了终端标题栏显示完整路径的功能。

    如果想要终端颜色丰富一些,我们可以开启~/.bashrc中的force_color_prompt=yes参数,这样终端会用颜色来区分各种不同的项目,提高可阅读性

    (原文地址: http://xieshaohu.wordpress.com/2010/07/26/ubuntu%E8%AE%BE%E7%BD%AEredhat%E9%A3%8E%E6%A0%BC%E7%9A%84shell%E6%8F%90%E7%A4%BA%E7%AC%A6ps1%E5%B1%9E%E6%80%A7/

  • 相关阅读:
    Power of Cryptography
    Radar Installation
    Emag eht htiw Em Pleh
    Help Me with the Game
    89. Gray Code
    87. Scramble String
    86. Partition List
    85. Maximal Rectangle
    84. Largest Rectangle in Histogram
    82. Remove Duplicates from Sorted List II
  • 原文地址:https://www.cnblogs.com/jianyungsun/p/1971399.html
Copyright © 2011-2022 走看看