This is how to create a custom bash prompt that will change if the user is in a certain folder, but is standard anywhere else.
PS1="┌─╼ \$(if [[ \$PWD/ = \$HOME/anime/* ]]; then \ echo \"\[\e[1;35m\](\[\e[0;35m\] •\[\e[1;35m\]^ ω ^) \[\e[1;34m\]\$(pwd | sed 's|'$HOME/anime/'|アニメ |; s|'$HOME/anime'|アニメ |')\[\e[0m\]\" \ ; else \ echo \"\[\e[0;35m\]\u\[\e[1;36m\]::\[\e[0;32m\]\h \[\e[1;34m\]\w\[\e[0m\]\" \ ; fi)\n──╼ " |
This is useful for creating a custom prompt when the user in in their movies directory, but they have a standard prompt anywhere else.
This is the prompt the user will get.
┌─╼ jason::Yog-Sothoth ~ ──╼
Very nice looking prompt.
This is a simpler prompt that any user could have, but the above solution is quite cool.
PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] ' |
Just goes to show, that the bash prompt can change depending on where you are in the filesystem, or even if you are the root user or not.
jason@Yog-Sothoth ~/anime $ su Password: root@Yog-Sothoth:/home/jason/anime#
Just like the example above, this shows the prompt changing when I switch to the root user from a standard Linux account.
Here is a simpler version of the anime prompt script.
PS1="┌─╼ \$(if [[ \$PWD/ = \$HOME/anime/* ]]; then \ echo \"\e[1;35m(\e[0;35m •\e[1;35m^ ω ^) \e[1;34m\$(pwd | sed 's|'"$HOME"'/anime/\{0,1\}|アニメ |')\e[0m\" \ ; else \ echo \"\e[0;35m\u\e[1;36m::\e[0;32m\h \e[1;34m\w\e[0m\" \ ; fi)\n──╼ " |
This cool tip might be very useful for someone who wants to create a conditional bash prompt that changes as they move around the filesystem and want to know if they are in their favourite anime folder so they can watch Gunsmith Cats or Bleach.