Estilos de Bash Prompts

Publicado por edps em 26/10/2011

[ Hits: 8.555 ]

Blog: https://edpsblog.wordpress.com/

 


Estilos de Bash Prompts



Como o prometido na dica do meu .bashrc para o Arch Linux, aqui postarei alguns estilos de bash_prompts que encontrei pela Net, tal dica também publiquei em meu blog.

Começarei pelo estilo que estou usando atualmente:

# esse é o meu bash_prompt atual, já descomentado,
# caso opte por outro comente todas as linhas e
# descomente a linha do estilo escolhido

function elite()
{
local GRAY="\[\033[1;30m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local CYAN="\[\033[0;36m\]"
local LIGHT_CYAN="\[\033[1;36m\]"
case $TERM in
xterm*)
local TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
local TITLEBAR=""
;;
esac
local GRAD1=$(tty|cut -d/ -f3)
PS1="$TITLEBAR\
$GRAY-$CYAN-$LIGHT_CYAN(\
$CYAN\u$GRAY@$CYAN\h\
$LIGHT_CYAN)$CYAN-$LIGHT_CYAN(\
$CYAN\#$GRAY/$CYAN$GRAD1\
$LIGHT_CYAN)$CYAN-$LIGHT_CYAN(\
$CYAN\$(date +%H%M)$GRAY/$CYAN\$(date +%d-%b-%y)\
$LIGHT_CYAN)$CYAN-$GRAY-\
$LIGHT_GRAY\n\
$GRAY-$CYAN-$LIGHT_CYAN(\
$CYAN\$$GRAY:$CYAN\w\
$LIGHT_CYAN)$CYAN-$GRAY-$LIGHT_GRAY "
PS2="$LIGHT_CYAN-$CYAN-$GRAY-$LIGHT_GRAY "
}
PROMPT_COMMAND=elite

# esse é o meu bash_prompt atual, já descomentado,
# caso opte por outro comente todas as linhas e
# descomente a linha do estilo escolhido

Linux: 
Estilos de Bash Prompts
A seguir demonstrarei mais alguns e ao final segue mais uma imagem com os primeiros estilos citados, cada um está como na sequência com que foram postados, lembrando que somente o estilo acima está descomentado (todos os demais estão comentados), bastará remover o sinal '#' do início da linha começada por #PS1... e comentar a do estilo que foi substituído.

Para a edição do arquivo ~/.bashrc, use o editor de sua preferência.

E seguem alguns estilos de bash_prompts para a personalização de seu terminal:

#PROMPT_COMMAND='history -a;echo -en "\033[m\033[38;5;2m"$(( `sed -nu "s/MemFree: [\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed -nu "s/MemTotal: [\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo`/1024 ))MB"\t\033[m\033[38;5;55m$(< /proc/loadavg)\033[m"'

#PS1="\[\033[01;31m\]\h\[\033[00m\]\[\033[01;32m\] \ [\033[01;32m\]\u \[\033[00;33m\]\w\n\[\033[01;30m\]$ \ [\033[00m\]"

#PS1='\[\033[1;34m\]\u \[\033[1;32m\]@\[\033[1;34m\] \h \ [\033[1;30m\]::\[\033[1;37m\] $(_chomp_path $(pwd)) \[\033[1;30m\]%%\ [\033[0m\] '

#PS1='\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\ [\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\ [\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\ [\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ '

#PS1='\[\033]0;\w\007\]\[\e[35;1m\]\u\[\e[0m\]\ [\e[32m\]@\h\[\e[34m\]\w \[\e[33m\]\$ \[\e[0m\]'

#PS1='\[\033[01;31m\]\u\[\033[01;36m\]@\[\033[01;32m\]\h\ [\033[01;33m\]:\[\033[01;33m\]\w\n\[\033[01;31m\]\$ \ [\033[00;32m\]'

#PS1="\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\ [\033[00m\] "

#PS1="\[\033[0;31m\][\u] [ \w ] \[\033[0m\] \n # "

#PS1="\[\033[0;33m\][\!]\`if [[ \$? = "0" ]]; then echo "\\ [\\033[32m\\]"; else echo "\\[\\033[31m\\]"; fi\`[\u.\h: \`if [[ `pwd|wc -c|tr -d " "` > 18 ]]; then echo "\\W"; else echo "\\w"; fi\`]\$\ [\033[0m\] "; echo -ne "\033]0;`hostname -s`:`pwd`\007"

#PS1="\[\033[0;33m\][\!]\`if [[ \$? = "0" ]]; then echo "\\ [\\033[32m\\]"; else echo "\\[\\033[31m\\]"; fi\`[\u.\h: \`if [[ `pwd|wc -c|tr -d " "` > 18 ]]; then echo "\\W"; else echo "\\w"; fi\`]\$\ [\033[0m\] "; echo -ne "\033]0;`hostname -s`:`pwd`\007"

#PS1="\[\033[0;34m\][\u] \[\033[0;0m\]\w \[\033[0m\]$ "

#PS1="\[\033[0;34m\][\u] \[\033[0;31m\][ \w ] \[\033[0m\] \n >> "

#PS1="\[\033[0;34m\][\u] \[\033[0;33m\][ \t ] \[\033[0;31m\][ \w ] \[\033[0m\] \n >> "

#PS1='\[\033[1;30m\][\[\033[0;37m\]${PIPESTATUS}\[\033[1;30m\]:\ [\033[0;37m\]${SHLVL}\[\033[1;30m\]:\[\033[0;37m\]\j\ [\033[1;30m\]][\[\033[1;34m\]\u\[\033[0;34m\]@\ [\033[1;34m\]\h\[\033[1;30m\]:\[\033[0;37m\]`tty | sed s/\\\\\/dev\\\\\/\//g`\[\033[1;30m\]]\ [\033[0;37m\][\[\033[1;37m\]\W\[\033[0;37m\]]\[\033[1;30m\] \$\[\033[00m\] '

#PS1="[\[\033[1;34m\]\u\[\033[0m\]@\h \W]\\$ "

#PS1="[\!] \033[1;36m[ \u@\h ]\033[1;32m\] [ \t ] [ \d ]\n\033[1;33m\ [[ \w ] \033[00m\\n\[\e[30;1m\](\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\]) \ [\e[0m\] $: "

#PS1="[\[\033[32m\]\w]\[\033[0m\]\n\[\033[1;36m\]\u\ [\033[1;33m\]-> \[\033[0m\]"

#PS1="\[\033[34m\] \u@\h `tty | sed 's/\/dev\///'` \t \d \ [\033[35m\]\w/ \n\[\033[34m\] $\[\033[0m\] "

#PS1="\[\033[35m\]\t\[\033[m\]-\[\033[36m\]\u\ [\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\ [\033[m\]\$ "

#PS1="\[\033[36m\] \u@\h `tty | sed 's/\/dev\///'` \t \d \ [\033[32m\]\w/ \n\[\033[36m\] $\[\033[0m\] "

#PS1=">\[\033[s\]\[\033[1;\$((COLUMNS-4))f\]\$(date +%H:%M)\ [\033[u\]"

#PS1='C:${PWD//\//\\\}>'

#PS1='${debian_chroot:+($debian_chroot)}\[[ \033[01;31m\]\w\[\033[00m\]] '

#PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\]'

#PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\] \[\e[1;37m\]'

#PS1='\[\e[0;32m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[1;32m\]\$\[\e[m\]'

#PS1='\e[1;31;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;31m[dir.= \w] \# > \e[0;0m'

#PS1='\[\e[1;31m\][\[\e[0;37m\]\u\[\e[1;31m\]@\ [\e[0;37m\]\h \W\[\e[1;31m\]]\$\[\e[0m\] '

#PS1='\[\e[1;31m\][\u@\h \W]\$\[\e[0m\] '

#PS1='\[\e[1;32m\]\u@\H:\[\e[m\] \[\e[1;37m\]\w\ [\e[m\]\n\[\e[1;33m\]hist:\! \[\e[0;33m\] \ [\e[1;31m\]jobs:\j \$\[\e[m\] '

#PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '

#PS1='\e[1;33;47m\u \e[1;32;47mon \h \e[1;35;47m\d \@\e[0;0m\n\e[1;34m[dir.= \w] \# > \e[0;0m'

#PS1="\[\e[1;33m\] > \[\033[0m\]"

#PS1='\[\e[1m\]\h:\w\$\[\e[0m\] '

#PS1="\[\e]2;\u@\H \w\a\e[30;1m\]>\[\e[0m\] "

#PS1="\[\e[30;1m\]\w> \[\e[0m\]"

#PS1="\[\e[36;1m\]\u@\[\e[32;1m\]\H> \[\e[0m\]"

#PS1="\[\e[37;1m\]-{\[\e[34;1m\]\u@\h\[\e[37;1m\]}-\n\ [\e[37;1m\](\[\e[34;1m\]\w: \$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[37;1m\])\n--> \ [\e[0m\]"

#PS1='\[\e[41m\]\[\e[1;37m\] \u \[\e[47m\]\[\e[1;30m\] \W \[\e[0m\]\[\e[1;37m\]\[\e[42m\] # \[\033[0m\] '

#PS1='\[\e[45m\]\[\e[1;37m\] \u@\h \[\e[47m\]\ [\e[1;30m\] \W \[\e[0m\]\[\e[1;37m\]\[\e[42m\] > \ [\033[0m\] '

#PS1='\[\e[m\n\e[0;33m\][$$:$PPID \j:\!\[\e[0;33m\]]\ [\e[0;36m\] \T \d \[\e[1;34m\][\[\e[1;34m\]\u@\H\ [\e[1;31m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\ [\e[1;30m\]] \[\e[1;31m\]\w\[\e[0;30m\] \n($SHLVL:\!)\$ '

#PS1="\`if [ \$? = 0 ]; then echo \[\e[33m\]^_^\[\e[0m\]; else echo \ [\e[31m\]O_O\[\e[0m\]; fi\`[\u@\h:\w]\\$ "

#PS1="\n\[\033[32;1m\]It's \t\[\033[33;1m\] Currently browsing \ [\033[1;36m\]\w \[\033[33;1m\]directory\n\[\033[34;1m\]\`if [ \$? = 0 ]; then echo \[\e[37m\]Last Command Was Successfully Executed \[\e[32m\]^_^\ [\e[0m\]; else echo \[\e[37m\]Smeggin Hell !!! Last Command Was Unknown \ [\e[32m\]O_O\[\e[0m\]; fi\` \n\[\033[31m\]What is thy bidding, my master? \n\n\[\033[34;1m\]"

#PS1="\n\[\033[35m\]\$(/bin/date)\n\[\033[32m\]\w\n\ [\033[1;31m\]\u@\h: \[\033[1;34m\]\$(/usr/bin/tty | /bin/sed -e 's:/dev/::'): \ [\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files \[\033[1;33m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\033[0m\] -> \[\033[0m\]"

#PS1="\n\[$bldgrn\][\[$txtrst\]\w\[$bldgrn\]]\[$bldwht\]\n\ [$bldwht\][\[$txtrst\]\t\[$bldwht\]]\[$bldylw\]$ \[$txtrst\]"

#PS1="\n#--[\[\e[1;36m\]\u@\h\[\e[m\]]-[\ [\e[1;34m\]\w\[\e[m\]]-[\$(date +%k:%M)]-->\n"

#PS1="\n\[\e[30;1m\]\[\016\]l\[\017\](\ [\e[34;1m\]\u@\h\[\e[30;1m\])-(\[\e[34;1m\]\j\ [\e[30;1m\])-(\[\e[34;1m\]\@ \d\[\e[30;1m\])->\ [\e[30;1m\]\n\[\016\]m\[\017\]-(\[\[\e[32;1m\]\w\ [\e[30;1m\])-(\[\e[32;1m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, \$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])--> \[\e[0m\]"

#PS1="\n\[\e[30;1m\]?(\[\e[34;1m\]\u@\h\[\e[30;1m\])-(\ [\e[34;1m\]\j\[\e[30;1m\])-(\[\e[34;1m\]\@ \d\ [\e[30;1m\])->\[\e[30;1m\]\n??(\[\e[32;1m\]\w\ [\e[30;1m\])-(\[\e[32;1m\]$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files, $(/bin/ls -lah | /bin/grep - m 1 total | /bin/sed 's/total //')b\[\e[30;1m\])--> \[\e[0m\]"

#PS1="\n\[\e[32;1m\](\[\e[37;1m\]\u\[\e[32;1m\])-(\ [\e[37;1m\]jobs:\j\[\e[32;1m\])-(\[\e[37;1m\]\w\ [\e[32;1m\])\n(\[\[\e[37;1m\]! \!\[\e[32;1m\])-> \ [\e[0m\]"

#PS1="\n\[\e[m\][\[\033[01;32m\]\w\[\e[m\]] [\t] \n\ [\033[01;33m\]$ \[\033[00m\]"

#PS1="\t \u@\h\$ "

#PS1="\t \u@\h `tty | sed 's/\/dev\///'` \w \$ "

#PS1="\u@\h\$ "

#PS1="\u@\h `tty | sed 's/\/dev\///'` \w \$ "

#PS1='[\u@\h \W]\$ '

#PS1="\u@\h [\w] \$ "

#PS1="\u `tty | sed 's/\/dev\///'` [\W] \$ "


##########################
# Nate Mitchell's (Kasyx's) Bash Prompt.
##########################
# function prompt() {
# Black="\e[30m"
# Red="\e[31m"
# Green="\e[32m"
# LightGreen="\e[32;1m"
# Blue="\e[34m"
# LightBlue="\e[34;1m"
# NC="\e[0m" # No Color
# PS1="\[$LightGreen\033(0\154\033(B\][\ [\033(0\161\161\033(B$Green\][\[$Red\]\u@\h\[$Green\]]\ [\033(0\161\033(B\][\[$Red\]\w\[$Green\]]\ [\033(0\161\033(B\][\[$Red\]\!\[$Green\]]\ [\033(0\161\161\033(B\]]\n\ [$LightGreen\033(0\155\161\033(B$Green\][\[$Red\]\#\[$Green\]]\ [\033(0\161\033(B\][\[$Red\]\$\[$Green\]]\ [\033(0\161\161\033(B\][\[$NC\]"
# PS2="> "
# }
# prompt


######################
# Emmanuel Rouat's shell prompt
# (no final escolha entre powerprompt ou fastprompt).
######################
# if [[ "${DISPLAY%%:0*}" != "" ]]; then
# HILIT=${red} # remote machine: prompt will be partly red
# else
# HILIT=${cyan} # local machine: prompt will be partly cyan
# fi
# # --> Replace instances of \W with \w in prompt functions below
# # + --> to get display of full path name.
# function fastprompt()
# {
# unset PROMPT_COMMAND
# case $TERM in
# *term | rxvt )
# PS1="${HILIT}[\h]$NC \W > \[\033]0;\${TERM} [\u@\h] \w\007\]" ;;
# linux )
# PS1="${HILIT}[\h]$NC \W > " ;;
# *)
# PS1="[\h] \W > " ;;
# esac
# }
# function _powerprompt()
# {
# LOAD=$(uptime|sed -e "s/.*: \([^,]*\).*/\1/" -e "s/ //g")
# }
# function powerprompt()
# {
# PROMPT_COMMAND=_powerprompt
# case $TERM in
# *term | rxvt )
# PS1="${HILIT}[\A - \$LOAD]$NC\n[\u@\h \#] \W > \
# \[\033]0;\${TERM} [\u@\h] \w\007\]" ;;
# linux )
# PS1="${HILIT}[\A - \$LOAD]$NC\n[\u@\h \#] \W > " ;;
# * )
# PS1="[\A - \$LOAD]\n[\u@\h \#] \W > " ;;
# esac
# }
# #powerprompt
# fastprompt

Observação:

Caso use o ZSH ao invés do BASH, o membro @SMarcell tem umas configs interessantes.

É isso aí, é como uma coletânea de estilos que encontrei pela Net, alguns na Wiki do Chakra etc.

Agora falta o .bashrc para o Debian...

Outras dicas deste autor

APT e Synaptic no Fedora

Turbinando o sidux

Concatenando arquivos PDF

Proxy no Chrome / Chromium em outros WMs

Painel Tint2 com lançadores de aplicativos

Leitura recomendada

Ligando/Desligando o PC-Speaker (beep) do terminal

Melhores sites para quem gosta de games

Projeto de Software Livre do Governo

TPP - Apresentação de slides em modo texto

Atualizando Slackware 12.0 para -current (pré 12.1)

  

Comentários
[1] Comentário enviado por xerxeslins em 27/10/2011 - 11:56h

Cool, man!

[2] Comentário enviado por removido em 28/10/2011 - 14:03h

Thanks, xerxes!



Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts