Shell
I use bash. The variable which controls the prompt string is PS1(prompt string 1). So in my .bash_profile, I can add this:export PS1="[\u@\h:\W, \@, \d]> " #custom prompt options whoami@hostname\current working directory\time\date
Here is a table of the options:
Description | csh* | ksh | bash | tcsh* | zsh |
---|---|---|---|---|---|
Current working directory | $CWD | $PWD | \w | %/ | %/ |
Current working directory, with one's home directory by `~' | $CWD:t | $PWD##*/ | \W | %~ | %~ |
Full hostname | 'uname -n' | 'uname -n' | N/A | %M | %M |
Hostname up to the first '.' | `hostname -s` | `hostname -s` | \h | %m | %m |
Start (stop) boldfacing mode | %B (or %b) | N/A | N/A | %B (or %b) | %B (or %b) |
Start (stop) standout mode | %S (or %s) | N/A | N/A | %S (or %s) | %S (or %s) |
Start (stop) underline mode | %U (or %u) | N/A | N/A | %U (or %u) | %U (or %u) |
User name | `whoami` | `logname` | \u | %n | %n |
The shell's tty that the user is logged in on | %l | N/A | N/A | %| | %| |
The current history number | %h | N/A | \! | %h (or %!) | %h (or %!) |
Name of the shell | N/A | N/A | \s | N/A | N/A |
Time of day in 12-hour hh:mm AM/PM | %t | N/A | \@ | %t (or %@) | %t (or %@) |
Time of day in 24-hour hh:mm | %T | N/A | \A | %T | %T |
Time of day in 12-hour with seconds hh:mm:ss AM/PM | %p | N/A | \T | %p | N/A |
Time of day in 24-hour with seconds hh:mm:nn | %P | N/A | \t | %P | %* |
The day in 'dd' format | %D | N/A | N/A | %D | N/A |
The month in 'Mon' format | %w | N/A | N/A | %w | N/A |
The month in 'mm' format | %W | N/A | N/A | %W | N/A |
The year in 'yy' format | %y | N/A | N/A | %y | N/A |
The year in 'yyyy' format | %Y | N/A | N/A | %Y | N/A |
The date in "Weekday Month Date" format | N/A | N/A | \d | N/A | N/A |
The date in day-dd format | N/A | N/A | N/A | N/A | %w |
The date in Mon/dd/yy format | N/A | N/A | N/A | N/A | %W |
The date in yy-mm-dd format | N/A | N/A | N/A | N/A | %D |
The weekday in 'Day' format | %d | N/A | N/A | %d | N/A |
Description | csh* | ksh | bash | tcsh* | zsh |
I mainly find stuffs about shell from the link below:
How to change your shell prompt You can find a lot of things about shell from this site.
Eshell
As to eshll, I got information from EmacsWiki: Eshell PromptThe Eshell prompt is generated by the function stored in ‘eshell-prompt-function’. When moving through the buffer, eshell also needs to know which lines start with a prompt. Therefore, whatever ‘eshell-prompt-function’ prints must be matched by ‘eshell-prompt-regexp’.
In my emacs init file, I add this:
(setq eshell-prompt-function (lambda () (concat " $ ")))
Though I don't know much about elisp, but I think it's quite clear what it means. And I also learned two command of emacs:
- C-h m: describe mode
- C-h v: describe variable
Now my shell prompt is simple and clear, just my style :)
No comments:
Post a Comment