Ubuntu / Debian / Arch linux 通用
$ sudo leafpad /etc/bash.bashrc
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
改為
# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
. /etc/bashcolor
然後建立 /etc/bashcolor
$ sudo leafpad /etc/bashcolor
safe_term=${TERM//[^[:alnum:]]/?} # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
&& type -P dircolors >/dev/null \
&& match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true
if ${use_color} ; then
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if type -P dircolors >/dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
else
eval $(dircolors)
fi
fi
if [[ ${EUID} == 0 ]] ; then
# root color 這裡是 root 終端機提示字元的配色
. /etc/bashcolor-root
else
# user color 這裡是 User 終端機提示字元的配色
. /etc/bashcolor-user
fi
alias ls='ls --color=auto'
alias grep='grep --colour=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
else
if [[ ${EUID} == 0 ]] ; then
# show root@ when we don't have colors
PS1='\u@\h \W \$ '
else
PS1='\u@\h \w \$ '
fi
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs
Ubuntu / Debian
/etc/bashcolor-root 內容
$ sudo leafpad /etc/bashcolor-root
PS1='${debian_chroot:+($debian_chroot)}\[\033[1;31m\]\u\[\033[1;32m\]@\[\033[1;32m\]\h\[\033[1;32m\]: \[\033[1;36m\]\W \[\033[1;33m\]\$ \[\033[0m\]'
/etc/bashcolor-user 內容
$ sudo leafpad /etc/bashcolor-user
PS1='${debian_chroot:+($debian_chroot)}\[\033[1;31m\]\u\[\033[1;32m\]@\[\033[1;32m\]\h\[\033[1;32m\]: \[\033[1;36m\]\W \[\033[1;33m\]\$ \[\033[0m\]'
Arch Linux
/etc/bashcolor-root 內容
$ sudo leafpad /etc/bashcolor-root
PS1='\[\033[1;31m\]\u\[\033[1;32m\]@\[\033[1;32m\]\h\[\033[1;32m\]: \[\033[1;36m\]\W \[\033[1;33m\]\$ \[\033[0m\]'
/etc/bashcolor-user 內容
$ sudo leafpad /etc/bashcolor-user
PS1='\[\033[1;34m\]\u\[\033[1;32m\]@\[\033[1;32m\]\h\[\033[1;32m\]: \[\033[1;36m\]\w \[\033[1;33m\]\$ \[\033[0m\]'
刪除~./bash.bashrc 即時生效
###################
顏色配置說明
###################
範例:mint@Extensa-2510G: /media/mint $
PS1='\[\033[1;34m\]\u\[\033[1;32m\]@\[\033[1;32m\]\h\[\033[1;32m\]: \[\033[1;36m\]\w \[\033[1;33m\]\$ \[\033[0m\]'
第一組顏色 USER
\[\033[1;34m\]\u
第二組顏色 @
\[\033[1;32m\]@
第三組顏色 HOST
\[\033[1;32m\]\h
第四組顏色 :
\[\033[1;32m\]:
第五組顏色 路徑
\[\033[1;36m\]\w
第六組顏色 $
\[\033[1;33m\]\$
第七組顏色 輸入文字 (無設定:預設白)
\[\033[0m\]'
顏色-------------------
30 設置黑色前景
31 設置紅色前景
32 設置綠色前景
33 設置黃色前景
34 設置藍色前景
35 設置紫色前景
36 設置青色前景
37 設置白色前景
40 設置黑色背景
41 設置紅色背景
42 設置綠色背景
43 設置黃色背景
44 設置藍色背景
45 設置紫色背景
46 設置青色背景
47 設置白色背景