Tutorial by Examples

When the last command in an interactive bash instance is done, the evaluated PS1 variable is displayes. Before actually displaying PS1 bash looks whether the PROMPT_COMMAND is set. This value of this var must be a callable program or script. If this var is set this program/script is called BEFORE th...
PS2 is displayed when a command extends to more than one line and bash awaits more keystrokes. It is displayed too when a compound command like while...do..done and alike is entered. export PS2="would you please complete this command?\n" # now enter a command extending to at least two l...
When the select statement is executed, it displays the given items prefixed with a number and then displays the PS3 prompt: export PS3=" To choose your language type the preceding number : " select lang in EN CA FR DE; do # check input here until valid. break done
PS4 is displayes when bash is in debugging mode. #!/usr/bin/env bash # switch on debugging set -x # define a stupid_func stupid_func(){ echo I am line 1 of stupid_func echo I am line 2 of stupid_func } # setting the PS4 "DEBUG" prompt export PS4='\nDEBUG level:$SHLVL ...
PS1 is the normal system prompt indicating that bash waits for commands being typed in. It understands some escape sequences and can execute functions or progams. As bash has to position the cursor after the displayes prompt, it needs to know how to calculate the effective length of the prompt strin...

Page 1 of 1