![]() |
![]() |
| Linux news | Newbie's Linux manual | Linux links | Link us | ||
| The Linux columns | Book reviews | ||
| DistroWatch + TuxReports | October 28, 2002 | |
Contents | Previous | Next | Download
Three files allow you to customise the shell for each user account:
| File | Description |
| ~/.bash_logout | Commands to be run when you log-out. |
| ~/.bash_profile | Things to be done when you log-in. Notably, the setting of environment variables (especially PATH). |
| ~/.bashrc | Called by ~/.bash_profile to set aliases. |
To customise your prompt, you need to change the PS1 (primary prompt string) environment variable.
- 1 -
Enter:
vi ~/.bash_profile
- 2 -
To the end of this file add something like:
PS1='Enter command: '
- 3 -
Rather than log-out and log-in to activate the change, just enter:
. .bash_profile
Note:
In a terminal window, the above won't be made permanent until you logout.
For your shell-prompt to be more informative, include any of the following character sequences:
| Sequence | Displays | Example output |
| \d | Date. | "Thu Dec 20" |
| \h | First part of hostname. | "localhost" |
| \H | Hostname. | "localhost.localdomain" |
| \j | Number of jobs currently managed by shell. | "1" |
| \l | Basename of shell's terminal device name. | "tty2" (equivalent in X: "2") |
| \n | Newline character. | |
| \s | Name of shell. | "bash" |
| \v | Shell version. | "2.05" |
| \V | Shell version, plus patchlevel. | "2.05.8" |
| \t | Time, in 24-hour HH:MM:SS format. | "14:39:12" |
| \T | Time, in 12-hour HH:MM:SS format. | "02:39:12" |
| \@ | Time, in 12-hour am/pm format. | "02:39pm" |
| \u | Username. | "john" |
| \w | Current working directory. | "~/mywork" |
| \W | Current working directory, basename only. | "mywork" |
| \! | History number of this command. | "1033" |
| \$ | "#" if root user, otherwise, "$". | "$" |
| \\ | Backslash character. | "\" |
An alias is when you enter something and it means something else. For example:
- 1 -
Enter:
vi ~/.bashrc
- 2 -
Add the following lines to the file:
alias x=startx alias df='df -h' alias cls='clear; ls'
Here entering x at the shell prompt will be interpreted as startx, entering df will be interpreted as df -h, and entering cls will be interpreted as clear and then ls.
- 3 -
Rather than log-out and log-in to activate the change, just enter:
. .bashrc
Note:
In a terminal window, the above won't be made permanent until you logout.
Contents | Previous | Next | Download
| About us | |
| Latest stable kernel: 2.4.19 | Latest development kernel: 2.5.44 Copyright © 1998-2002 Linuxdot.org. Linux ® is a registered trademark of Linus Torvalds. |
|