Skip to content

Instantly share code, notes, and snippets.

@jared-hughes
jared-hughes / lolps1.bash
Last active June 1, 2022 11:42 — forked from duckythescientist/lololps1.bash
Rainbow colored bash prompt PS1 string
lolps1() {
PREV_EXIT_CODE=$?
# PS1 rainbow modified from https://gist.github.com/duckythescientist/8338f028e018fd3fecae58e4f1c45def
# Replace $HOME with ~
mypwd=${PWD/#$HOME/"~"}
# Make a persistent, incrementing seed to make a smooth rainbow effect from line to line
if [ -z ${LOLCAT_SEED+x} ]; then LOLCAT_SEED=1; else let "LOLCAT_SEED += 1"; fi
PS1=$(echo " $mypwd" | lolcat --force --freq 0.3 --seed $LOLCAT_SEED 2>/dev/null)
# Strip the "reset colors to normal" commands
PS1=$(echo "$PS1" | sed $'s/\033\[0m//g')