[TAG] Just Bad and Wrong... yet cool
Benjamin A. Okopnik
ben at linuxgazette.net
Sat Oct 15 02:18:40 MSD 2005
On Fri, Oct 14, 2005 at 11:32:06AM +0100, Jimmy O'Regan wrote:
> Raj shekhar wrote:
> >in infinite wisdom Jimmy O'Regan spoke thus on 10/14/05 06:09:
> >
> >>Rick Moen wrote:
> >>
> >>>"bash is terrifying me again":
> >>>http://www.livejournal.com/users/mendel/128965.html
> >>>
> >>>Bash pseudo-sockets: Oh my!
> >>>
> >>>followed by:
> >>>"Dude, you've got a smiley in your prompt."
> >>
> >>
> >>
> >>Followed by:
> >>
> >>:) fishsticks$ false
> >>:( fishsticks$
> >
> >
> >How did he do that. I want something like that too. If anyone knows,
> >do tell.
> >
>
> ``
> jimregan at jimmy ~
> $ echo $PS1
> \[\033]0;\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $
>
> jimregan at jimmy ~
> $ smiley () { if [ $? == 0 ]; then echo ':)';else echo ':(';fi; }
>
> jimregan at jimmy ~
> $ PS1="\$(smiley) \h$ "
> :) jimmy$ false
> :( jimmy$ true
> :) jimmy$
> ''
Darn it, Jimmy, you always beat me. What, you have a fast connection or
something? :)
My way was just slightly different:
``
# More-or-less undocumented Bash-ism - a C-style trinary operator
smiley () { echo -e ":\\$(($??50:51))"; }
''
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://linuxgazette.net *
More information about the TAG
mailing list