How to print current bash prompt?

后端 未结 6 1065
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 08:20

The question is simple. I want to evaluate current value of PS1 in my bash script.

All materials on google point to tutorials on pimping it up, but I wa

6条回答
  •  眼角桃花
    2020-12-15 08:56

    I would get it like this:

    echo $PS1
    

    And then edit it with an editor. After that for the test (this is set while the session is active):

    PS1='\[\033[1m\]\[\033[34m\]\u\[\033[90m\]@\[\033[01;35m\]\h:\[\033[01;32m\]\W\[\033[0m\]$ '
    

    (\u is for user, \h is for host, \w is for full path and \W is for short path)

    And if I like it I will make it permanent by changing the value of PS1 in ~/.bashrc

    P.S.:

    If you want to see all global variables:

    printenv
    

    OR:

    printenv 
    

提交回复
热议问题