How to customise the other shell?

Answer Posted / kiran penujuri

On my machine, the prompt may look like this:
[kiran@54001 kins]$ _

Here "kiran" is my login name, "54001" is the name of the
computer, the second "kins" is the name of my current
working directory, and "_" represents the cursor.

The prompt is set by the environmental variable called
PS1. To display the current setting, I can use:

echo $PS1

The system-wide setting of the prompt (for all users on the
system) is in the file /etc/bashrc which on my system
contains such a line:

PS1="[\u@\h \W]\$ "

To customize the prompt, I can edit the file /etc/bashrc
(as root) and insert almost any text inside the quotation
marks. Here is the meaning of some special codes I may also
choose to use:

\u - username of the current user (= $LOGNAME),
\h - the name of the computer running the shell
(hostname),
\H - entire hostname,
\W - the base of the name of the current working
directory,
\w - the full name of the current working directory,
\$ - display "$" for normal users and "#" for the
root,
\! - history number of the current command,
\# - number of the current command (as executed in the
current shell),
\d - current date,
\t - current time (24-hr),
\T - current time (12-hr) - bash 2.0 only,
\@ - current time (AM/PM format) - bash 2.0 only,
\s - name of the shell,
\a - sound alarm (beep),
\j - number of jobs the user has,
\n - new line,
\\ - backslash,
\[ - begin a sequence of non-printable characters,
\] - end a sequence of non-printable characters,
\nnn - the ASCII character corresponding to the octal
number nnn.
$(date) - output from the date command (or any other
command for that matter),

Here is an example on how to add colour.
PS1="\[\033[1;32m\][\u@\h \W]\$\[\033[0m\] "

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 3 standard streams in linux?

573


How do I run a script on mac?

570


how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?

3605


Write a script to print the first 10 elements of fibonacci series.

1768


how will you find the total disk space used by a specific user?

580






What are types of shells?

549


Explain about debugging?

606


What is meant by dos operating system?

575


Where are cowrie shells found?

580


What is the way to do multilevel if-else's in shell scripting?

664


Explain about the exit command?

570


What is in a script?

571


What is a beat in a script?

548


Tell something about the super block in shell scripting?

574


Why are there shells on the beach?

597