In addition to the environment, shells maintain a similar set of variables for their own use. These variables are not passed down to child processes, and are only used by the shell.
Shell variables can be arbitrary, but each shell also treats certain variable names specially. One common example is the shell variable that stores the shell prompt.
In Bourne-shell derivatives, this variable is called PS1. To set a shell variable in Bourne-shell derivatives, we use a simple assignment. ( The export command above actually sets a shell variable called TERM and then exports it to the environment. )
shell-prompt: PS1="peregrine: "
In C shell derivatives, the variable is called
prompt
, and is set using the set
command:
shell-prompt: set prompt="peregrine: "
Shell prompt variables may contain certain special symbols that represent dynamic information they you might want to include in your shell prompt, such as the host name, command counter, current working directory, etc. Consult the documentation for your shell for details.
In all shells, you can view the current shell variables by typing set with no arguments:
shell-prompt: set