Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@emilyaherbert
Last active December 20, 2018 00:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emilyaherbert/bd444915f1ec20ae5d3975bafe8171bc to your computer and use it in GitHub Desktop.
Save emilyaherbert/bd444915f1ec20ae5d3975bafe8171bc to your computer and use it in GitHub Desktop.
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