

Halloween Bash Profile Generator - langer
http://xta.github.com/HalloweenBash/

======
Tyr42
One option that is missing that I really thing is useful is

    
    
        wincolour=$yellow
        errorcolour=$red
        # To provide a coloured version of $?, wrapped in ().  Used in PS1
        pretty_exit_code(){
          LAST_COMMAND_STATUS=$?
          if [ $LAST_COMMAND_STATUS = 0 ];
          then echo -e "$wincolour($LAST_COMMAND_STATUS)$black";
          else echo -e "$errorcolour($LAST_COMMAND_STATUS)$black";
          fi
        }
    

Which just provides the exit code of the last command, but coloured
differently for failure or success.

~~~
dllthomas
Interesting. I've been using $PIPESTATUS at the start of my prompt for a while
now.

~~~
michaelhoffman
I use this, which allows a similar effect but is enabled for PIPESTATUS, and
also does some good things for eterm and screen.

    
    
       PIPESTATUS_REGEX="^ +$"
    
       # check to see if any of the pipe statuses don't start with 0
       # ${_CMD_PIPESTATUS[@]#0} results in null if they all do
       _PIPESTATUS="
           _CMD_PIPESTATUS=(\${PIPESTATUS[@]})
           if [[ \"\${_CMD_PIPESTATUS[*]#0}\" && ! \"\${_CMD_PIPESTATUS[*]#0}\" =~ \$PIPESTATUS_REGEX ]]
           then
               _RES_STR=\" [\${_CMD_PIPESTATUS[*]}]\";
           else
               _RES_STR=''
           fi"
    
        export PROMPT_COMMAND="$_PIPESTATUS; $PROMPT_COMMAND"
    
        if [[ $TERM = screen || $_TERM = screen ]]; then
            _RESET_PROMPT="\[\033k\033\\\\\]"
        else
            _RESET_PROMPT=""
        fi
    
        if [ $TERM = "eterm-color" ]; then
            # XXX: this is going to break things when you start
            # use $INSIDE_EMACS to test whether we should use \u?
            _ETERM_PROMPT="\[\033AnSiTu \u\012\033AnSiTc \w\012\033AnSiTh \H\012\]"
        else
            _ETERM_PROMPT=""
        fi
    
        export PS1="\n$_ETERM_PROMPT\[\033[32m\]\u@\h \[\033[33m\]\w\[\033[35m\]\$_RES_STR\[\033[0m\]\n${_RESET_PROMPT}\\$ "
        unset _RESET_PROMPT

~~~
myhf
It's cool to also see the name of the signal that caused exit status > 128\.
Sadly this only fits in a tweet if it can assume the possible signal names are
listed contiguously, which isn't so on 64-bit Linux these days.

    
    
      S=(`trap -l`);e(){ for N in ${PIPESTATUS[@]};do ((N>128))&&echo ${S[$((2*N-257))]}||echo $N;done;};trap $'echo "\e[41m Exit "`e`" \e[m"' ERR

~~~
michaelhoffman
That's a great idea. I've rewritten my own version to use these signals
instead of numbers where possible.

------
cjg_
Nice!

A bug report, space tokens should not exhaust. Currently you can at max have 2
spaces, the one that is in the config by default and one from the available
tokens.

~~~
rexf
Thanks for opening up an issue in the repo.

------
levesque
Where is the @ character?? How am I going to make the classic prompt?

    
    
        user@comp:Folder$

~~~
rexf
Thanks to WillBooth, you're now able to use the @ character. I've merged in
his pull request <https://github.com/xta/HalloweenBash/pull/5>

------
mcgain
Brilliant idea. Well done! Change the name because this will be useful
throughout the full year.

------
rexf
Hey everyone,

Thanks for checking out the bash profile generator! I'm a student at Flatiron
School[1] NYC (where we have electricity in NYC, no small feat today) and this
project came about when we were learning to setup our CLIs in the first week.

Please let me know if you have any comments/feedback on twitter: @rexfeng

[1] <http://flatironschool.com/>

~~~
jgw
Fun project!

I balked, however, at "deciphering web pages to do simple things like
displaying the time". All of the prompt escape codes are on the bash man page.
That's not a criticism, mind you[1] - just a pointer at the fact that as you
develop as a command-line guru, you'll find much information is right there at
your finger tips in man pages.

Best of luck in your studies!

[1] No, really. I spend all my life on the command line - it's second nature
to me. On the other hand, I wouldn't have a clue where to begin to do a little
web app like yours - which probably makes me an amusing old oddity on HN :)

~~~
michaelhoffman
For bash, the info documentation is probably better than man, but as someone
who is very familiar with it, I would say it sometimes needs a little
deciphering.

------
Draiken
Very nice! Not sure why it's halloween tho, should be named something else :)

~~~
pyre
"Halloween Bash" as in a Halloween party, I'm guessing. Not exactly a
'timeless' name, but seeing as it was put up on Halloween...

------
Symmetry
Very nice. I sort of with there was an easy way to do fish style prompt paths
in bash (/home/username/bin -> /h/u/bin), but that's hardly this excellent
website's fault. I guess I'm just annoyed at being tied to bash due to ROS.

~~~
jdp
Here's one from the Arch mailing list. Also does the ~ expansion for home
directories: [http://www.mail-archive.com/arch-
general@archlinux.org/msg07...](http://www.mail-archive.com/arch-
general@archlinux.org/msg07374.html)

~~~
Symmetry
Thanks! With this complementing the git status function I already had, my
prompt is now 20% cooler.

------
paupino_masano
I love this idea - especially for those that are unfamiliar with BASH yet
still want to customize their command line experience. Unfortunately due to a
previous HN article I now use zsh - would love to see a zsh prompt generator
too!

------
asdfprou
At first I wondered how you managed to extract my username and then I realized
it was hardcoded when I looked through the code.

------
swah
Great impleentation, but its odd that there a limited number of elements you
might want many, like spaces.

------
agumonkey
As ugly as awesome ;)

------
chyld
Congrats Avi. Your students are killing it.

