PS1='[\[`if test $? -eq 0; then echo "\e[1;32m"; else echo "\e[1;31m";
fi`\]$?\[\e[0m\]]-[\[\e[0;34m\]\h\[\e[0m\]]-[\[\e[0;34m\]\w\[\e[0m\]]\[\n\]\$
'

Where is that awesome post about the CRC24 to get a nice <unique> color for
each hostname ?
There: https://www.mail-archive.com/[email protected]/msg136871.html

On Fri, Aug 28, 2015 at 11:54 AM, Patrick Dohman <[email protected]
> wrote:

> My back to SCO additions…
>
>
>  #---------------------------------#
> # Print the current directory, hostname & user#
>  #---------------------------------#
>
>  HOST=`hostname`
>  PS1='$(print -n "[${USER}@${HOST%%.*} ";[[ "$HOME" == "$PWD" ]] && print
> -n "~" ||([[ "${PWD##*/}" == "" ]] && print -n "/    " || print -n
> "${PWD##*/}");print "]$")'
>
>   #***************************************
>   HISTFILE=~/.ksh_history
>   export HISTFILE
>   HISTSIZE=500; export HISTSIZE
>   #****************************************
>
>
>   #---------------------------------#
>   #  a few Korn/Bash shell aliases  #
>   #---------------------------------#
>
>   alias l="ls -la"
>   alias vi=“vim"
>
> Regards
> Patrick
>
>
> > On Aug 27, 2015, at 7:36 PM, T B <[email protected]> wrote:
> >
> > Resurrecting this not-too-old thread.  You might find this one useful if
> > you run CARP firewalls which gives you a dynamic prompt telling you the
> > master/backup/other status.
> >
> > function fwStatus {
> >        IFCONFIG=`ifconfig -a | grep carp:`
> >        NUMCARPS=`echo "$IFCONFIG" | wc -l`
> >        BACKUPCARPS=`echo "$IFCONFIG" | grep 'carp: BACKUP' | wc -l`
> >        MASTERCARPS=`echo "$IFCONFIG" | grep 'carp: MASTER' | wc -l`
> >
> >        if [[ "$MASTERCARPS" == "$NUMCARPS" ]]; then
> >                printf master
> >        elif [[ "$BACKUPCARPS" == "$NUMCARPS" ]]; then
> >                printf backup
> >        else
> >                printf other
> >        fi
> > }
> >
> > HOSTNAME=`hostname -s`
> > PS1='${USER}@${HOSTNAME}:${PWD} ($(fwStatus)) $ '
> >
> >
> > On Wed, Aug 5, 2015 at 1:43 AM, Sean Kamath <[email protected]>
> > wrote:
> >
> >> On Aug 2, 2015, at 8:49 AM, [email protected] wrote:
> >>
> >>>> never
> >>>> thought of using a shell function in .profile till I read this thread.
> >>>
> >>> ...
> >>>
> >>> Functions has always been impressive once you move past the alias
> >>> shortcomings (can't handle arguments etc), so also worth a read the
> >>> "Functions" section.
> >>
> >>
> >> Functions have been amazingly useful and impressive for a very long
> time.
> >> They are also not limited to ksh.  In fact, my introduction to this very
> >> useful aspect of shell programming was from Sun's rcS script, which has
> >> this:
> >>
> >> # Simulates cat in sh so it doesn't need to be on the root filesystem.
> >> #
> >> shcat() {
> >>        while [ $# -ge 1 ]; do
> >>                while read i; do
> >>                        echo "$i"
> >>                done < $1
> >>                shift
> >>        done
> >> }
> >>
> >>
> >> There have been times when I've been on systems in single user mode
> >> without filesystems, and knowing how to do some things we typically use
> >> external programs for in the shell can be a lifesaver, like "echo *" as
> a
> >> poor man's "ls".
> >>
> >> If your directory isn't *that* large, 'for i in *;  do echo $i; done |
> wc
> >> -l' works well.  Well, for some definition of 'well'.
> >>
> >> My point is that shell functions allow you to do some fairly complex
> >> stuff, and if you're careful, you can avoid execs.  There are places the
> >> shell forks, however.  It can be a fun exercise to find them with
> profiling
> >> tools. :-)
> >>
> >> Sean
>
>


--
() ascii ribbon campaign - against html e-mail
/\

Reply via email to