Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
git config --global color.ui true
alias ls='ls --color=auto'
alias dmesg='dmesg --color=always'
alias grep='grep --color=always'
alias fgrep='fgrep --color=always'
alias egrep='egrep --color=always'
alias gcc='gcc -fdiagnostics-color=always'
alias pacman='pacman --color=always'
14:09:35 j0 olleg@petrel:~
$ time sleep 10
real 0m10.009s
user 0m0.000s
sys 0m0.000s
14:09:51 j0 olleg@petrel:~
$
local DIRWIDTH
(( DIRWIDTH = ${COLUMNS} / 3 ))
local CUR="[ %$DIRWIDTH<..<%~%<< ]"
PROMPT="$DARK_GREEN$CUR$DEFAULT ->"
df -hP .|sed -n '2p'|awk -F' ' '{print $4}' 
$(ERR="$?"; if [[ "$ERR" != "0" ]]; then printf "\033[01;37m(%.*s)\033[00m " $ERR $ERR; fi) $PS1
hg_branch() {
BRANCH=`hg branch 2> /dev/null | awk '{print "(hg:"$1")"}'`
if [[ $BRANCH == *release* ]]
then
BRANCH="\e[31m$BRANCH"
fi
if [[ $BRANCH == *default* ]]
then
BRANCH="\e[31m$BRANCH"
fi
echo -e $BRANCH
}
$(__git_ps1 "(git:%s)")$(hg_branch)

set_prompt () {
Last_Command=$? # Must come first!
Blue='\[\e[01;34m\]'
White='\[\e[01;37m\]'
Red='\[\e[01;31m\]'
Green='\[\e[01;32m\]'
Reset='\[\e[00m\]'
FancyX='\342\234\227'
Checkmark='\342\234\223'
# Add a bright white exit status for the last command
PS1="$White\$? "
# If it was successful, print a green check mark. Otherwise, print
# a red X.
if [[ $Last_Command == 0 ]]; then
PS1+="$Green$Checkmark "
else
PS1+="$Red$FancyX "
fi
# If root, just print the host in red. Otherwise, print the current user
# and host in green.
if [[ $EUID == 0 ]]; then
PS1+="$Red\\h "
else
PS1+="$Green\\u@\\h "
fi
# Print the working directory and prompt marker in blue, and reset
# the text color to the default.
PS1+="$Blue\\w \\\$$Reset "
}
PROMPT_COMMAND='set_prompt'
Скрипт не мой, где взял — не помню. Но огромное человеческое спасибо автору за это.
#!/bin/bash
#------------------------------------------------------------------------------+
#Color picker, usage: printf ${BLD}${CUR}${RED}${BBLU}"Hello!)"${DEF} |
#-------------------------+--------------------------------+-------------------+
# Text color | Background color | |
#-----------+-------------+--------------+-----------------+ |
# Base color|Lighter shade| Base color | Lighter shade | |
#-----------+-------------+--------------+-----------------+ |
BLK='\e[30m'; blk='\e[90m'; BBLK='\e[40m'; bblk='\e[100m' #| Black |
RED='\e[31m'; red='\e[91m'; BRED='\e[41m'; bred='\e[101m' #| Red |
GRN='\e[32m'; grn='\e[92m'; BGRN='\e[42m'; bgrn='\e[102m' #| Green |
YLW='\e[33m'; ylw='\e[93m'; BYLW='\e[43m'; bylw='\e[103m' #| Yellow |
BLU='\e[34m'; blu='\e[94m'; BBLU='\e[44m'; bblu='\e[104m' #| Blue |
MGN='\e[35m'; mgn='\e[95m'; BMGN='\e[45m'; bmgn='\e[105m' #| Magenta |
CYN='\e[36m'; cyn='\e[96m'; BCYN='\e[46m'; bcyn='\e[106m' #| Cyan |
WHT='\e[37m'; wht='\e[97m'; BWHT='\e[47m'; bwht='\e[107m' #| White |
#--------------------------------------------------------------------+---------+
# Effects |
#------------------------------------------------------------------------------+
DEF='\e[0m' #Default color and effects |
BLD='\e[1m' #Bold\brighter |
DIM='\e[2m' #Dim\darker |
CUR='\e[3m' #Italic font |
UND='\e[4m' #Underline |
INV='\e[7m' #Inverted |
COF='\e[?25l' #Cursor Off |
CON='\e[?25h' #Cursor On |
else
#------------------------------------------------------------------------------+Для использования в .bashrc нужно его "засорсить": source colors.sh.
Разноцветные терминалы