Live data from Hacker News

Halloween Bash Profile Generator

xta.github.com

21–27 of 27 posts

Re: Halloween Bash Profile Generator

#21

Earlier quoted context omitted.

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

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 _R…

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

Re: Halloween Bash Profile Generator

#22
post #19

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.

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...

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

Re: Halloween Bash Profile Generator

#24
post #4

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 coloure…

Just added exit status to the page. Thanks for the suggestion.

Re: Halloween Bash Profile Generator

#27
post #21

Earlier quoted context omitted.

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 _R…

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

That's a great idea. I've rewritten my own version to use these signals instead of numbers where possible.
Post reply on HN