Skip to content

Instantly share code, notes, and snippets.

@Phoenix2k
Last active April 14, 2021 15:41
Show Gist options
  • Save Phoenix2k/65ef585d1a7cc4ad7ea04817e4a553ba to your computer and use it in GitHub Desktop.
Save Phoenix2k/65ef585d1a7cc4ad7ea04817e4a553ba to your computer and use it in GitHub Desktop.
Rainbow shell logo
function displayLine () {
echo $1 | sed -e "s+{{username}}+@$USER+g"
}
function printLogo () {
local logo=$1
if [ -e "$logo" ]; then
echo ""
while IFS= read -r line; do
displayLine $line
done < $logo
echo ""
fi
}
# Other configurations …
printLogo $HOME/.asciilogo | lolcat

Rainbow shell logo

Displays a logo with your username in rainbow colours every time you open a new terminal window.

Compatibility

Should work with Bash and ZSH on MacOS / Linux.

Requirements

Installation

  1. Download the .asciilogo file and place it in your home directory 1.
  2. Open your existing shell configuration ~/.zshrc, ~/.bashrc (Linux) or ~/.bash_profile (MacOS) in a code/text editor.
  3. Place the displayLine and printLogo functions somewhere before the end of your configuration.
  4. Place the printLogo $HOME/.zshlogo | lolcat 2 line at the end of your configuration where you want the logo to be printed.
  5. Save and restart your terminal

You should now see a colourful 🌈 logo with your username printed on the side.

1 Press Command + Shift + . (MacOS) or Control + Shift + h (Ubuntu) to display hidden dot files on your system.

2 If you decided to put the logo somewhere else, replace the $HOME/.asciilogo with the location and name of your logo.

Text replacements

If you want the logo to display other dynamic content, you can expand the displayLine function by piping more SEDs in a row and adding more {{stuff}} to your logo:

echo $1 | sed -e "s+{{username}}+@$USER+g" | sed -e "s+{{something}}+@$REPLACEMENT+g"

Note that $USER is a global variable and prints out your current username. The $REPLACEMENT in this example would contain whatever you want the {{something}} to be replaced with:

$REPLACEMENT=Content you want to display

This should be placed somewhere at the beginning of your configuration file.

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