Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rotating PS1 colors, place in .bashrc.
declare -a promptarr=("e" "m" "i" "l" "y" "@" "e" "m" "i" "l" "y" "h" "e" "r" "b" "e" "r" "t")
declare -a colorsarr=("\[\033[0;31m\]" "\[\033[0;33m\]" "\[\033[0;32m\]" "\[\033[0;34m\]" "\[\033[0;35m\]" "\[\033[0;36m\]")
coloroffset=0
promptarrlen=${#promptarr[@]}
colorsarrlen=${#colorsarr[@]}
set_prompt() {
promptstr=""
colorcount=0
for (( i=0; i<${promptarrlen}; i++ ));
do
colorindex=$(( $colorcount+$coloroffset ));
colorindex=$(( $colorindex%${colorsarrlen} ));
promptstr+=${colorsarr[$colorindex]};
promptstr+=${promptarr[$i]}
colorcount=$(( $colorcount+1 ));
done
if (( $coloroffset < $(( $(( ${colorsarrlen}-1))*-1)) )); then
coloroffset=-1
else
coloroffset=$(( $coloroffset-1 ))
fi
promptstr+="\[\033[0;37m\]: \W$ "
PS1=$promptstr
}
PROMPT_COMMAND=set_prompt
@sezna
Copy link

sezna commented Dec 20, 2018

i use dis erry day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment