I've been customizing my terminal prompt, and found that it's possible to change the "secondary prompt". However, I have no way to test the changes I make to this one so I was wondering if a simple script could be written to test the new
PS2 The value of this parameter is expanded as with PS1 and used as the secondary prompt string. The default is ``> ''.
The "secondary prompt string" is what is shown when you have multi-line input. For example:
$ echo 'foo >bar'
> shown above is
PS2. If I were to change that, I would see it as soon as I tried any multi-line command:
$ PS2="%" $ echo 'foo %bar'
Ways to run multi-line commands include:
- Open quotes (single or double) and hit enter without closing them.
Add a backslash to the end of a command and hit enter:
$ echo foo \ >
Use a HEREDOC:
$ echo <<<END ## hit enter
As for doing it with a script, that's really not needed but you can simply write a script that prints
#!/usr/bin/env bash printf "PS2 : %s\n" "$PS2"