LINUX.ORG.RU

как сделать баш цветным?


0

0

хочу немного разукрасить bash (приглашение, completion-list) и основные команды (у меня только ls цветной), а то когда смотришь в журнале в konsole, нехрена не разберёшь

anonymous

~/.bashrc:
#!/bin/bash



function prompt_command {

TERMWIDTH=${COLUMNS}

hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
usernam=$(whoami)
totdirs=$(/bin/ls -lA | /bin/grep ^d | wc -l | /bin/sed 's: ::g')
totfiles=$(/bin/ls -lA | /bin/grep ^- | wc -l | /bin/sed 's: ::g')
totlinks=$(/bin/ls -lA | /bin/grep ^l | wc -l | /bin/sed 's: ::g')
totsize=$(/bin/ls -lAh | /bin/grep -m 1 total | /bin/sed 's/total //')
newPWD="${PWD}"

let promptsize=$(echo -n "--[${usernam}@${hostnam}]--[${totdirs} ${totfiles}
${totlinks} ${totsize}b]--[${PWD}]--" \
| wc -c | tr -d " ")
let fillsize=${TERMWIDTH}-${promptsize}
fill=""

while [ "$fillsize" -gt "0" ]
do
fill="${fill}-"
let fillsize=${fillsize}-1
done

if [ "$fillsize" -lt "0" ]
then
let cut=3-${fillsize}
newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cut\}\)\(.*\)/\2/")"
fi
}

PROMPT_COMMAND=prompt_command

function minitty {

local NO_COLOR="\[\033[0m\]"
local RED="\[\033[01;32m\]"
local BLUE="\[\033[01;34m\]"

PS1="$RED\$$BLUE: $NO_COLOR"
}

function meditty {

local NO_COLOR="\[\033[0m\]"
local RED="\[\033[01;32m\]"
local BLUE="\[\033[01;34m\]"

local USERNAME="\u"
local HOSTNAME="\h"

local WORKDIR="\W"


PS1="$NO_COLOR[$BLUE$USERNAME$NO_COLOR in $GREEN\w$NO_COLOR]$BLUE\$$NO_COLOR "
}

function maxitty {

local NO_COLOR="\[\033[0m\]"
local WHITE="\[\033[01;37m\]"
local GREEN="\[\033[01;32m\]"
local BLUE="\[\033[01;34m\]"
local CYAN="\[\033[01;36m\]"

local USERNAME="\u"
local HOSTNAME="\h"
local NEW_LINE="\n"

local NRFILES="\$(ls -lA | grep ^- | wc -l | /bin/sed 's: ::g')"
local NRDIRS="\$(ls -lA | grep ^d | wc -l | /bin/sed 's: ::g')"
local NRLINKS="\$(ls -lA | grep ^l | wc -l | /bin/sed 's: ::g')"

local TOTALSIZE="\$(/bin/ls -lAh | /bin/grep -m 1 total | /bin/sed 's/total //')"

local WORKDIR="\w"

PS1="$NO_COLOR--[$GREEN\wGREEN]-- $NEW_LINE$GREEN\$$BLUE:$NO_COLOR"
}

# Set default fancy prompt (maxitty)
meditty

# Colors for ls, etc.
eval `dircolors -b /etc/DIR_COLORS`

alias ls="ls --color=auto"
alias md="mkdir"
alias rd="rm -r"


alias cd..="cd .."
alias cd...="cd ../.."
alias cd....="cd ../../.."
alias on="sudo /usr/sbin/ppp-on"
alias off="sudo /usr/sbin/ppp-off"

alias untarz="tar -xvzf"
alias untarb="tar -xvjf"

alias grep="grep --color=auto"


#`nvshell -f m`
#`nvshell -a m`
##uncomment the following to activate bash-completion:
[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.