The PS1
variable is only one of literally hundreds of environment variables. Don't worry, you don't have to know them all! The following are a few very useful ones:
Most of these are self-explanatory; however, a few need more discussion. The PATH
environment variable is where commands are searched for in the filesystem.
The echo
command is used to display the contents of a variable:
Prepending a dot to the
PATH
means the program will be looked for in the current directory first, before searching the rest of the path. This is very useful during the code development for example. Do this by running:export PATH=".:$PATH"
The
EDITOR
variable can be set to your favorite text editor. Most people usevi (or vim)
; however, you can point it to the one you want. If you change this, be sure to use the full path. To change theEDITOR
variable do this:export EDITOR=/lewis/bin64/kw
An
export
can be removed by setting it to nothing:export EDITOR=
By convention, environment variables are usually written in uppercase. View the man pages and/or search Google for more information on these variables.
Think of these environment variables just as you would if you were using a programming language. In this case, the type of the variable is determined by the OS. For example, you could type A=1
or A="This is a string"
.
The OS knows the difference. Also, there is variable scope. Notice I did not use export
above. That means this A
is local to this shell. Only exporting a variable will make it available to other shells (after sourcing the file).