Bash Prompt Example: Color/User/Date/Time/Host/Path 2014-03-03 13:23
/ / /
Bash Prompt Example: Color / User / Date / Time / Host / Path
1. User => \u
代碼:
\u
2. Color
代碼:
BOLD => \[\033[1m\]
RED => \[\033[31m\]
BOLD READ => \[\033[1;31m\]
GREEN => \[\033[32m\]
BOLD GREEN => \[\033[1;32m\]
YELLOW => \[\033[33m\]
BOLD YELLOW => \[\033[1;33m\]
BLUE => \[\033[34m\]
BOLD BLUE => \[\033[1;34m\]
OFF => \[\033[m\] or \[\e[0m\]
3. Host => \h
e.g. username@hostname prmpt
代碼:
\u@\h
4. Date (No Year) => \d
e.g. Mon Mar 03
代碼:
\d
5. Date (YYYY-MM-DD) => \D{Format}
e.g. 2012-08-15
代碼:
\D{%Y-%m-%d}
6. Unix Time Stamp => \D{%s}
e.g. 1365656566
代碼:
\D{%s}
7. Absolute Path => \w
e.g. ~username/myfolder/
代碼:
\w
8. New Lines => \n
e.g.
代碼:
\n
9. Related Path => \W
代碼:
\W
10. Time => \A \t
代碼:
\A => 14:31 (24 HH:II)
\t => 14:31:21 (24 HH:II:SS)
\T => 02:31:21 (12 HH:II Without AM/PM)
\@ => 02:31 PM (AM/PM will be translated up to your locale)
11. History Count => \#
代碼:
\# ==> It will show how many commands in this shell (bash history counting)
Some bash prompt examples
Example #1: 'user@host $ '
代碼:
export PS1='\u@\h $ '
Example #2: Two lines with (1) First line Date Time (2) 2nd Line '>> ' prompt
代碼:
export PS1='\n\u@\h \[\d \t\] \w \n>> '
Example #3: BOLD + Colorful upon Example #2
代碼:
export PS1='\n\[\033[1;32m\]\u@\h \t \[\e[33m\]\w\[\e[0m\]\n>> '
See also: http://xor.tw/4zlm2
________________
美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀



