Krysti.Engineer Official Chat
You are viewing an inferior version of the site because your browser does not support WebP. Do upgrade to something like Chrome or Firefox. Loading websites like this causes them to require a fallback set of images and they are almost always lower quality and larger in size.

A Very Emotional Bash Prompt

This is just something I randomly threw together one day cuz I thought it would be funny if the bash prompt was a little more emotional over it's exit codes. This will look good in most terminals with a basic font like 'monospace' as well as some options here for 'cool-retro-term' with TERM set to 'xterm-256color'.
2022-07-17T:00:00:00+00:00 July 18 2022 00:00:00

nano -w ~/.bashrc

For the sake of an example, this will load the prompt into the current user's .bashrc login script.

return_face() {
	# You can select one of these types of setups.
	# Modern.. I guess
	happy="😀|🥳|😊|😘"
	rawr="🤣|😆|😂"
	wtf="🤬|😡|😠"
	kill="☠️|💀|☣️"
	
	# Alternative, nice for cool-retro-term pixelated or in general.
	# happy="(✿◠‿◠)|ฅ(^•ﻌ•^)ฅ|(◠‿◠✿)|(❀❛ᴗ❛)"
	# rawr="(◠△◠✿)|(⚆_⚆)|(︣ʘ‸︣ʘ✿)"
	# wtf="(☞゚ヮ゚)|(ノ◕ヮ◕)ノ*:・"
	# kill="(ノಠ益ಠ)ノ彡┻━┻|(づ。◕‿‿◕。)づ"
	
	# These should show up if you have FontAwesome setup on 
	# your system. Not good for cool-retro-term.
	# happy="|||"
	# rawr="||"
	# wtf="||"
	# kill="||"	
	# You can change the reaction faces color values below here.
	case $@ in 
		0)
		fret="happy"
		color="${PINK}"
		;;
		1|2|126|127|128)
		fret="rawr"
		color="${NEONAPPLE}"
		;;
		130|137)
		fret="kill"
		color="${RED}"
		;;
		*)
		#echo "Debug others ${@}"
		fret="wtf"
		color="${DARKRED}"
		;;
	esac
	faces=($(echo ${!fret} | tr "|" "\n"))
	fct=$((${#faces[@]}))
	shuf=$((RANDOM % $fct))
	# Leave it
	echo -en "${color}${faces[$shuf]}${reset}"
}
rainbow() {
	# You can change this colors array. These are from the 256 colors.
	# Some default rainbow palettes below, pick one.
	# Krysti Kandi
	colors=(129 135 99 141 171 177 207 213 134 140 128)
	# Midnight
	# colors=(25 26 27 31 37 44 63 69 75 111 117 151)
	# Inferno
	# colors=(52 88 124 160 198)
	# Limescape
	# colors=(22 28 35 42 47 77 84 112 119 149 155 184 192)
	# Warm
	# colors=(13 95 131 136 144 167 174 180 202 210 216 224)
	# Deep Purple
	# colors=(55 93 129 165 171 201 207)
	[[ "$@" == "$HOME"* ]] && { param="${@/$HOME/"~"}"; } || param=$@
	str=`echo $param | grep -o .`
	n=0
	for x in $str
	do
	# Leave this
    echo -en "\001\e[38;5;${colors[$n]}m\002"
    # Especially leave this
    echo -n $x
	[ $n -lt $((${#colors[@]}-1)) ] && { let "n=n+1"; } || n=0
	done
}
prompt_cmd () {
	PEXIT=$?
	ccolor="${DARKPURPLE}" # Corner Color
	bcolor="${BOLD}${HOTPINK}" # Bracket Color
	dcolor="${SKYBLUE}" # Dash Color
	pcolor="${BLUE}" # Prompt Color
	reset="\001\e[0m\002" 
	tcorner="${ccolor}┌${reset}"
	bcorner="${ccolor}└${reset}"
	dash="${dcolor}-${reset}" 
	lbrak="${bcolor}[${reset}"
	rbrak="${bcolor}]${reset}"
	prmpt="${pcolor}\\$" 
    PS1="${tcorner}${lbrak}\$(rainbow \\u@\\h)${rbrak}${dash}${lbrak}\$(rainbow \\@)${rbrak}${dash}\n${bcorner}\$(return_face \${PEXIT}) ${lbrak}\$(rainbow \\w)${rbrak}${prmpt}${reset} "
}
# Some of my favourite colors defined
BOLD="\001\e[1m\002"
CYAN="\001\e[38;5;41m\002"
ICE="\001\e[38;5;123m\002"
BLUE="\001\e[38;5;63m\002"
SKYBLUE="\001\e[38;5;87m\002"
PINK="\001\e[38;5;213m\002"
HOTPINK="\001\e[38;5;201m\002"
DARKPURPLE="\001\e[38;5;56m\002"
PURPLE="\001\e[38;5;93m\002"
DARKRED="\001\e[38;5;88m\002"
RED="\001\e[38;5;124m\002"
YELLOW="\001\e[38;5;226m\002"
NEONAPPLE="\001\e[38;5;118m\002" 
GREEN="\001\e[38;5;42m\002" 
PWINK="\001\e[38;5;111m\002" 
PROMPT_COMMAND=prompt_cmd

Save this example somewhere. This script example can be loaded however you want, globally through the bashrc.d, bash.bashrc (or system-a-like situation), your ~/.bashrc or whatever. It just needs to execute it before you finish logging in, preferably somewhere at the end so other PS1 variables elsewhere don't overwrite this behaviour. This prompt is the same colours I use myself, however it's easy to figure out what to use to customize this so you can suit your needs or uncomment one of the presets in the rainbow function and customize the predefined colors in this script using the variables like '${NEONAPPLE}'.

#!/bin/bash
for i in {1..255} ; 
	do
		printf "\x1b[38;5;%sm%3d\e[0m " "$i" "$i";
		if (( i == 15 )) || (( i > 15 )) && (( (i-15) % 15 == 0 )); then
			printf "\n";
		fi; 
	done


Here you'll get a print out of all the 256 colour range you can use and their codes. Since we're using xterm-256color capable colours we will have to pay attention to the main method of printing these colours. Every colour of this foreground setting will start with \e[38;5; so \e[38;5;201m would be a hot pink and in bash it would print \001\e[38;5;201m\002 so we can bypass a bash bug that makes the formating be undesirable. As shown in the script above you will need to pass the '-e' switch with an echo command to parse these escape sequences. You may also use the PREDEFINED colors in the bashrc script at the bottom.
customized bash prompt

{
  "backgroundColor": "#000000",
  "fontColor": "#ffffff",
  "flickering": 0.0572,
  "horizontalSync": 0.0662,
  "staticNoise": 0.0563,
  "chromaColor": 0.7323,
  "saturationColor": 0.261,
  "screenCurvature": 0,
  "glowingLine": 0.0267,
  "burnIn": 0.1326,
  "bloom": 0.4531,
  "rasterization": 2,
  "jitter": 0,
  "rbgShift": 0,
  "brightness": 0.6041,
  "contrast": 0.7473,
  "ambientLight": 0,
  "windowOpacity": 1,
  "fontName": "PRO_FONT_SCALED",
  "fontWidth": 1,
  "margin": 0.5,
  "name": "Krysti xterm-256color",
  "version": 2
}

This is a preset you can import into cool-retro-term. Bear in mind some photo examples may have had modifications since.
customized bash prompt in cool-retro-term

Contact Krysti

@itskrystibitch Twitter Photo
GitHub:
@itskrystibitch
IRC:
Official Chat
Direct.Me:
@Krysti
Ko-fi:
@Krysti
Photos:
Virtual Krysti
E-Mail / Notify of errors:
coder [@] krysti.engineer
Please be patient contacting me, I don't really check much of social media or anything. If you use the IRC be sure to stick around because that's how IRC works, silly. :P