linuxbash

How to get bash PROMPT on linux?


We can use echo $PS1 to view

test@testauto:~$ echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
test@testauto:~$

But what I want is "test@testauto:~$" not "[\e]0;\u@\h: \w\a]${debian_chroot:+($debian_chroot)}\u@\h:\w$"

How can I get it?


Solution

  • For Bash

    echo "${PS1@P}"
    

    For ZSH

    echo "${(%%)PS1}"
    

    You can find more about this in this thread: How to print current bash prompt?