Customize your Terminal prompt
/boot/home/.profile and scan down until you find a line that reads:
Edit it so that it reads
The next time you open up Terminal, the prompt will report the current directory, no matter what you do. PWD is a Unix/Be command meaning Print Working Directory — you’ve just told Terminal to print the working directory every time it displays a prompt. If you’re a migrating DOS person, you’ll welcome this extra bit of information.
It should be pointed out that using the single quotes (”) are important. If you use double quotes (“”) instead, the prompt will be set to the current directory at the time of opening the terminal and then stay unchanged.
Reason is that within double-quotes all variables like $PWD are evaluated immediately, whereas within single quotes they aren’t. That means:
PS1=’$PWD> ‘ -> PS1 is in fact set to ‘$PWD> ‘
PS1=”$PWD> ” -> PS1 is in fact set to ‘/boot/home> ‘
You can further customize your prompt by including actual phrases, or anything you find useful or fun. For instance: /boot/home/ — What’s up, cap’n? >
Thanks to Lars Duening for the shell expansion details on this tip.
Just Sherrill (email@example.com) adds this information:
By setting parameters in your
.profile, there are seemingly endless ways to customize your Terminal prompt.
For example, inserting
PS1='$PWD' will make your prompt display the current working directory, which can be handy. However, as you work farther down a set of directories, your prompt can end up taking most of the line.
Instead, the string
W will print the name of the directory you are in, without the full path. You can even mix it with color commands. The following example gives you the current directory, without the path, but with a red colon at the end of the prompt.
There are lots of other things you can include in your Terminal prompt, listed below: (stolen from http://d oc.rmplc.co.uk/linux/LDP/HOWTO/Bash-Prompt-HOWTO-2.html, and probably available from many other places as well. Not all of these are useful yet on BeOS.)
a an ASCII bell character (07) d the date in "Weekday Month Date" format (e.g., "Tue May 26") e an ASCII escape character (033) h the hostname up to the first `.' H the hostname newline carriage return s the name of the shell, the basename of $0 (the portion following the final slash) the current time in 24-hour HH:MM:SS format T the current time in 12-hour HH:MM:SS format @ the current time in 12-hour am/pm format u the username of the current user v the version of bash (e.g., 2.00) V the release of bash, version + patchlevel (e.g., 2.00.0) w the current working directory W the basename of the current working directory ! the history number of this command # the command number of this command $ if the effective UID is 0, a #, otherwise a $ nn the character corresponding to the octal number nnn \ a backslash [ begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt ] end a sequence of non-printing characters
onyx m. reyes (firstname.lastname@example.org) adds still more information:
The prompt style has four elements: foreground color, background
color, effect (shadow or normal) and prompt script/functions.
The escape code template:
‘e[X;Y;Z + m A’ or ‘?33[X;Y;Z + m A’
the escape code can be “e” or “?33” its your preference.
You can arrange/exclude X, Y, Z in any order and as long as they are
seperated with a “;” and the last value has an “m” after it.
ps1=’e[40;01,37m $PWD e[m/>’
ps1=’e[01;34m $PWD e[m/>’
Use the escape sequence every time you want a change the style of
Finally, here is the list of colors codes and effects taken out
of my /boot/home/.profile (you can cut and past this if you want)
PS1='[e[0;36;44m e[m] [e[0;34;46m $PWD e[m] [e[1;37;40m DarkStar e[m]-['
- using the same forground and background color will make it
really hard to read.
- keep in mind that PS1 command will display spaces.
Posted in Terminal
(comments are closed).