Eu tinha o prompt do meu terminal personalizado, conforme este post.
No entanto, desde que migrei para o ArchLinux ele não funciona mais.
Assim, procurei e encontrei outro bash script que personaliza o prompt.
O prompt ficou assim agora:
![]() |
| De Diversos |
Usei a dica daqui: http://bbs.archlinux.org/viewtopic.php?id=84386
Editado em 22/06/2010:
Apesar do link acima, achei por bem colocar o passo a passo aqui também.
1 – Salve o código no final deste post com o nome de .zer0prompt no seu diretório home.
2 – edite o arquivo .bashrc, comentando a linha PS1 e insira o código a seguir:
source ~/.zer0prompt
zer0prompt
unset zer0prompt
Código do arquivo .zer0prompt:
#!/bin/bash
#
# zer0prompt
# By: Wes Brewer [zer0]
# Last updated: Nov 8, 2009
#
# Credit for ideas/info: Phil!'s ZSH Prompt, Bashish, TERMWIDE prompt
# Bash Prompt Howto
#
# Usage: Add the follwing lines to your ~/.bashrc file
# source ~/.zer0prompt
# zer0prompt
# unset zer0prompt
#
#### user config ####
#
## set colour theme
# options -- cyan, blue, green, red, purple, yellow, black, white, none
zpcl="cyan"
#
## set info colours
# colour ref -- http://www.gilesorr.com/bashprompt/howto/c333.html#AEN335
zi1="\[33[1;32m\]" # user@host:tty
zi2="\[33[1;35m\]" # current path
zi3="\[33[1;33m\]" # time
zi4="\[33[1;31m\]" # exit status
zi5="\[33[1;32m\]" # user identifier ($ or #)
#
## set time format
# options -- 12, 24, 12s, 24s
zptm="12"
#
## set line graphics to use
zg1="─"; zg2="┌"; zg3="└"; zg4="┤"; zg5="├"; zg6=">"; zg7="|"
#zg1="-"; zg2="+"; zg3="+"; zg4="|"; zg5="|"; zg6=">"; zg7="|"
#
#
#### code ####
# Use bash builtin checkwinsize option for terminals which fail to properly
# set the $COLUMNS variable. (bug workaround)
shopt -s checkwinsize
#
# if root user then colour user@host info and user identifier red.
[ "${UID}" = 0 ] && zi1="\[33[1;31m\]" && zi5="\[33[1;31m\]"
#
# This function is run at every prompt update, keeping our variables updated.
# Bash's PROMPT_COMMAND option handles this (see end of this function).
function pre_prompt {
# show exit code of last failed command
ZEXIT="${?}"
[ "$ZEXIT" = "0" ] && ZEXIT=""
#
ZPWD=${PWD/#$HOME/\~} # sorten home dir to ~
#
# set length of our important info
local infolength="$(whoami)@$(hostname):$(basename $(tty))$ZPWD"
# set length of our graphics
local gfxlength=23
#
# construct ZFILL size to fill terminal width (minus info/gfx lengths).
local fillsize
let fillsize=${COLUMNS}-${gfxlength}-${#infolength}
ZFILL=""
while [ "$fillsize" -gt "0" ]; do
ZFILL="$ZFILL$zg1"
let fillsize=${fillsize}-1
done
#
# determine how much to truncate ZPWD, if ZFILL can't shrink anymore.
if [ "$fillsize" -lt "0" ]; then
local cut=3-${fillsize} # some tricky math, 3-(-number)=+number
ZPWD="...${ZPWD:${cut}}"
fi
}
PROMPT_COMMAND=pre_prompt
#
# This function tells bash how to draw our prompt
function zer0prompt {
local zc0="\[33[0m\]" # clear all colors
local zc1="\[33[1;37m\]"
local zc2="\[33[0;37m\]"
#
# set colour theme
if [ "$zpcl" = "cyan" ]; then
local zc3="\[33[1;36m\]"; local zc4="\[33[0;36m\]"
elif [ "$zpcl" = "blue" ]; then
local zc3="\[33[1;34m\]"; local zc4="\[33[0;34m\]"
elif [ "$zpcl" = "green" ]; then
local zc3="\[33[1;32m\]"; local zc4="\[33[0;32m\]"
elif [ "$zpcl" = "red" ]; then
local zc3="\[33[1;31m\]"; local zc4="\[33[0;31m\]"
elif [ "$zpcl" = "purple" ]; then
local zc3="\[33[1;35m\]"; local zc4="\[33[0;35m\]"
elif [ "$zpcl" = "yellow" ]; then
local zc3="\[33[1;33m\]"; local zc4="\[33[0;33m\]"
elif [ "$zpcl" = "black" ]; then
local zc3="\[33[1;30m\]"; local zc4="\[33[0;30m\]"
elif [ "$zpcl" = "white" ]; then
local zc3="\[33[1;37m\]"; local zc4="\[33[0;37m\]"
else # no colour
local zc3=""; local zc4=""; local zc1=""; local zc2=""
zi1=""; zi2=""; zi3=""; zi4=""; zi5=""
fi
#
# set time format
if [ "$zptm" = "24" ]; then
local ZTIME="\A"
elif [ "$zptm" = "12s" ]; then
local ZTIME="\T"
elif [ "$zptm" = "24s" ]; then
local ZTIME="\t"
else
local ZTIME="\@"
fi
#
# set titlebar info if xterm/rxvt
case $TERM in
xterm*|rxvt*)
local TITLEBAR='\[33]0;\u (\w) [${COLUMNS}x${LINES}]07\]';;
*)
local TITLEBAR="";;
esac
#
# prompt
PS1="${TITLEBAR}\
$zc1$zg2$zg1$zc3$zg1$zc4$zg1$zg4$zi1\u@\h:\l$zc4$zg5$zg1$zc2$zg1$zg1$zc4\
\$ZFILL$zc3$zg1$zg1$zg1$zg1$zc1$zg1$zg1$zg1$zc3$zg1$zg1$zc4$zg1$zg4$zi2\
\$ZPWD$zc4$zg5$zg1$zc2$zg1
$zc3$zg3$zc4$zg1$zg4$zi3$ZTIME$zc4$zg7$zi5\\\$$zc4$zg5$zi4\
\$ZEXIT$zc2$zg1$zc3$zg6$zc0 "
#
# continuation prompt
PS2="$zc3$zg3$zc4$zg1$zg4$zi5\\\$$zc4$zg5$zc2$zg1$zc3$zg6$zc0 "
}



