Бергон интернет и телевизия
http://forum.bergon.net/

Bash Prompts
http://forum.bergon.net/viewtopic.php?f=3&t=51105
Страница 1 от 1

Автор:  Timbo [ 24 Фев 2010 17:22 ]
Заглавие:  Bash Prompts

Ще нахвърля малко идейки за яки bash prompts

Bashish: http://bashish.sourceforge.net


Код:

    red
='\e[0;31m'
    RED='\e[1;31m'
    blue='\e[0;34m'
    BLUE='\e[1;34m'
    green='\e[0;32m'
    GREEN='\e[1;32m'
    cyan='\e[0;36m'
    CYAN='\e[1;36m'
    NC='\e[0m' # No Color


    function powerprompt() {


     _powerprompt() {
        LOAD=$(uptime|sed -"s/.*: \([^,]*\).*/\1/" -"s/ //g")
        TIME=$(date +%H:%M:%S)
        OPENSHELLS=$(who|wc -l|sed -"s/ //g")
        UPTIME=$(uptime|sed -"s/.*up\([^,]*\).*/\1/" -"s/ //g")
     }


     PROMPT_COMMAND=_powerprompt


     case $TERM in
      xterm 
| dtterm | rxvt )
       PS1="${cyan}[Time: ${green}\${TIME}${cyan} | OpenShells: ${green}\${OPENSHELLS}${cyan} | Load: ${green}\${LOAD}${cyan} | Uptime: ${green}\${UPTIME}${cyan}]${NC}\n[\#.][\u@\h]:\w>  \[\033]0;[\u@\h] \w\007\
]"
 ;;
      linux )
       PS1="${cyan}[Time: ${green}\${TIME}${cyan} | OpenShells: ${green}\${OPENSHELLS}${cyan} | Load: ${green}\${LOAD}${cyan} | Uptime: ${green}\${UPTIME}${cyan}]${NC}\n[\#.][\u@\h]:\w>" ;;
      * )
       PS1="[Time: \${TIME} - Load: \${LOAD}]\n[\#.][\u@\h]:\w> " ;;
     esac
    
} 


резултат:
[Time: 16:22:00 | OpenShells: 2 | Load: 0.00 | Uptime: 7days]
[43.][user@trance]:~> ]

------------------------------------------

Код:
#!/bin/bash
# based on a function found in bashtstyle-ng 5.0b1
# Original author Christopher Roy Bratusek (http://www.nanolx.org)
# Last arranged by ayoli (http://ayozone.org) 2008-02-04 17:16:43 +0100 CET 

function pre_prompt {
newPWD="${PWD}"
user="whoami"
host=$(echo -n $HOSTNAME | sed -"s/[\.].*//")
datenow=$(date "+%a, %d %b %y")
let promptsize=$(echo -"в”Њ($user@$host ddd., DD mmm YY)(${PWD})в”ђ" \
                 | wc -| tr -" ")
let fillsize=${COLUMNS}-${promptsize}
fill=""
while [ "$fillsize" -gt "0" ] 
do 
    fill
="${fill}в”Ђ"
    let fillsize=${fillsize}-1
done
if 
[ "$fillsize" -lt "0" ]
then
    let cutt
=3-${fillsize}
    newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cutt\}\)\(.*\)/\2/")"
fi

}

PROMPT_COMMAND=pre_prompt

export black
="\[\033[0;38;5;0m\]"
export red="\[\033[0;38;5;1m\]"
export orange="\[\033[0;38;5;130m\]"
export green="\[\033[0;38;5;2m\]"
export yellow="\[\033[0;38;5;3m\]"
export blue="\[\033[0;38;5;4m\]"
export bblue="\[\033[0;38;5;12m\]"
export magenta="\[\033[0;38;5;55m\]"
export cyan="\[\033[0;38;5;6m\]"
export white="\[\033[0;38;5;7m\]"
export coldblue="\[\033[0;38;5;33m\]"
export smoothblue="\[\033[0;38;5;111m\]"
export iceblue="\[\033[0;38;5;45m\]"
export turqoise="\[\033[0;38;5;50m\]"
export smoothgreen="\[\033[0;38;5;42m\]"



case "$TERM" in
xterm
)
    PS1="$bblueв”Њв”Ђ($orange\u@\h \$(date \"+%a, %d %b %y\")$bblue)в”Ђ\${fill}в”Ђ($orange\$newPWD\
$bblue)в”Ђв”ђ\n$bblueв””в”Ђ($orange\$(date \"+%H:%M\") \$$bblue)в”Ђ>$white "
    ;;
screen)
    PS1="$bblueв”Њв”Ђ($orange\u@\h \$(date \"+%a, %d %b %y\")$bblue)в”Ђ\${fill}в”Ђ($orange\$newPWD\
$bblue)в”Ђв”ђ\n$bblueв””в”Ђ($orange\$(date \"+%H:%M\") \$$bblue)в”Ђ>$white "
    ;;    
    
*)
    PS1="в”Њв”Ђ(\u@\h \$(date \"+%a, %d %b %y\"))в”Ђ\${fill}в”Ђ(\$newPWD\
)в”Ђв”ђ\nв””в”Ђ(\$(date \"+%H:%M\") \$)в”Ђ> "
    ;;
esac

# bash_history settings: size and no duplicates and no lines w/ lead spaces
exportHISTCONTROL="ignoreboth"
export HISTSIZE=1024

# aliases #############################################

# enable color support of ls and also add handy aliases
eval `dircolors -b`
alias ls='ls --color=auto'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'

# some more ls aliases
alias ll='ls -lhX'
alias la='ls -A'
alias ldir='ls -lhA |grep ^d'
alias lfiles='ls -lhA |grep ^-'
#alias l='ls -CF'

# To see something coming into ls output: lss
alias lss='ls -lrt | grep $1'

# To check a process is running in a box with a heavy load: pss
alias pss='ps -ef | grep $1'

# usefull alias to browse your filesystem for heavy usage quickly
alias ducks='ls -A | grep -v -e '\''^\.\.$'\'' |xargs -i du -ks {} |sort -rn |head -16 | awk '\''{print $2}'\'' | xargs -i du -hs {}'

# cool colors for manpages
alias man="TERMINFO=~/.terminfo TERM=mostlike LESS=C PAGER=less man"

##########################################################
# enable programmable completion features (you don'
t need to enable
# this, if it's already enabled in /etc/bash.bashrc).
if [ -/etc/bash_completion ]; then
    
. /etc/bash_completion
fi

# CDPATH initialisation
CDPATH=.:~:/media/store:/media/sites



http://ayozone.org/wp-content/uploads/2008/02/bashrc.txt

Demo:
http://ayozone.org/wp-content/uploads/2008/02/fancy_prompt.png

Автор:  Krass [ 14 Авг 2012 12:23 ]
Заглавие:  Re: Bash Prompts

Яко!
(bow)

Автор:  alkaline [ 28 Авг 2019 16:16 ]
Заглавие:  Re: Bash Prompts

Косата ми беше станала ужасна и една колежка ми препоръча да пия рибено масло. На нея много й било помогнало, понеже преди и нейната коса била зле. И да ви кажа, не вярвах, но има голям ефект!

Страница 1 от 1 Часовете са според зоната UTC + 2 часа [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/