Can you set the prompt to a certain value using a script and a case statement?
This is not possible, since the PS1 value has to be passed to the parent, and this would involve somewhat more advanced shell programming skills.
For now, however, the problem can be solved sourcing the script in stead of letting the shell execute it. It does not have to be executable in that case, just like ~/.bashrc or /etc/profile, which are both read by the shell and not executed (they are not executable either).
So, this is mood.rc:
case "$1" in fine) PS1="\u@\h \w> " ;; bofh) PS1="What is it?! " ;; noisy) PS1="\a[\d \W]> " ;; *) echo "Use "$0" with fine or bofh as options" ;; esac
Since your shell has already been started, you do not need to include the first line of
or some comparable line.
Now source this file: (with the "." (dot) command) and one of the arguments defined in the case statement:
student9> . mood.rc bofh What is it?!