You can use something like this in your ~/.zshrc:
realPS1="$PS1"
changed=false
changePS1() {
$changed && {
PS1="%n (normal) in %~> "
#Or
PS1="$realPS1"
changed=false
: # <-- It might be not necessary add this `:`. This one
#represents a zero-status code (or successful).
} || {
PS1="%n (hidden)> "
changed=true
}
}
bindkey -s "^H" 'changePS1^M'
The code above will create a shortcut (using bindkey) with Ctrl + H to execute the changePS1 function. So basically what Ctrl + H does is to enable the hidden prompt and when you press Ctrl + H again will enable the normal prompt.
About $PS1 you should assign the values according to your needs. For example, this line PS1="%n (normal) in %~> " shows the prompt like this:
edgar (normal) in ~/Documents/Gitlab/Linux_programming>
where %n is the username and %~ the relative path of my current working directory.
However you can back up your real $PS1 (line realPS1="$PS1") and use the line PS1="$realPS1" instead of PS1="%n (normal) in %~> "
And about PS1="%n (hidden)> " that will show the following prompt:
edgar (hidden)>
and therefore you should assign your PS1 variable with your custom prompt but you don't have to use %~ to avoid printing the path.