How to customise the other shell?
Answers were Sorted based on User's Feedback
Answer / 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 |
You need to have one intiation script in your home
directory for the shell you want to customize. What ever
customization you want to the shell , put those things in
that file. When ever you login to that shell, the
initiation script will execute automatically.
For ex for bash shell the script is .bashrc
| Is This Answer Correct ? | 1 Yes | 0 No |
How will you connect to a database server from linux?
What is the equivalent of a file shortcut that we have a window on a linux system?
on “sed” command EmpData(Sample Database) 1122|j.b. saxena |g.m. |account |12/12/52|6000 2233|n.k. gupta |d.g.m |sales |31/12/40|9000 4545|anil agarwal |director |account |06/07/47|7500 5656|lalit choudhury |executive|marketing|07/09/50|5000 1265|chanchal singhvi|g.m. |admin |12/09/63|6000 0110|shyam saksena |chairman |marketing|12/12/43|8000 5566|jai sharma |director |account |23/12/89|7000 7733|jayant |d.g.m |sales |29/02/70|6000 1. From the above database substitute the delimiter of first 3 lines with “ : “ 2. From the above database substitute the delimiter with “ : ” 3. Insert the string “ XYZ Employees” in the first line. 4. Store the lines pertaining to the directors, d.g.m and g.m into three separate files. 5. Using address store first 4 lines into a file Empupdate. 6. Find the pattern “account” in the database and replaces that with “accounts”. 7. Select those lines which do not have a pattern “g.m”. 8. Insert a blank line after every line in the database.
What is the use of break command?
What is the need of including script interpreter in your shell script?
What exactly is a shell?
What is Path variable?What is its use?
How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?
what is the difference between sh & bash shell?
What is the difference between scripting and coding?
What is the way to do multilevel if-else's in shell scripting?
Create a bash shell script that removes all files whose names end with a "~" from your home directory and subdirectories. Name this script "cleanup.sh"