|
| 1 | +# Using Figlet and Lolcat for Eye-Catching Terminal Messages |
| 2 | + |
| 3 | +This guide will help you set up Figlet and Lolcat on Linux to create colourful, ASCII-styled terminal messages. We'll provide detailed instructions for both Ubuntu and Arch-based systems, along with tips to enhance your setup. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## **Step 1: Install Figlet** |
| 8 | + |
| 9 | +Figlet is a tool for generating ASCII art from text. Use the appropriate commands based on your Linux distribution: |
| 10 | + |
| 11 | +### **For Arch-based Systems (e.g., Arch, Manjaro):** |
| 12 | + |
| 13 | +```bash |
| 14 | +sudo pacman -S figlet |
| 15 | +``` |
| 16 | + |
| 17 | +### **For Ubuntu-based Systems (e.g., Ubuntu, Debian):** |
| 18 | + |
| 19 | +```bash |
| 20 | +sudo apt update |
| 21 | +sudo apt install figlet figlet-data |
| 22 | +``` |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## **Step 2: Install Lolcat** |
| 27 | + |
| 28 | +Lolcat adds vibrant rainbow colours to your terminal output, making your Figlet creations even more eye-catching. |
| 29 | + |
| 30 | +### **For Arch-based Systems:** |
| 31 | +```bash |
| 32 | +sudo pacman -S lolcat |
| 33 | +``` |
| 34 | + |
| 35 | +### **For Ubuntu-based Systems:** |
| 36 | +```bash |
| 37 | +sudo apt install lolcat |
| 38 | +``` |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## **Step 3: Install Additional Figlet Fonts** |
| 43 | + |
| 44 | +Expand your Figlet experience by adding more fonts to your system. Here’s how: |
| 45 | + |
| 46 | +### **Download and Install Fonts** |
| 47 | +1. Clone the community fonts repository: |
| 48 | + ```bash |
| 49 | + git clone https://github.com/xero/figlet-fonts.git ~/figlet-fonts |
| 50 | + ``` |
| 51 | +2. Move the fonts to the correct directory: |
| 52 | + ```bash |
| 53 | + sudo cp ~/figlet-fonts/* /usr/share/figlet/fonts |
| 54 | + ``` |
| 55 | + |
| 56 | +--- |
| 57 | + |
| 58 | +## **Step 4: Verify the Installation** |
| 59 | +Ensure everything is set up correctly: |
| 60 | + |
| 61 | +1. **List Available Fonts:** |
| 62 | + ```bash |
| 63 | + figlist |
| 64 | + ``` |
| 65 | + This command will display all of the available figlet font files on your system. |
| 66 | + |
| 67 | +2. **Output all fonts to a txt file:** |
| 68 | + |
| 69 | + To preview all of the available fonts, you can output them to a text file by running the following commands: |
| 70 | + ```bash |
| 71 | + cd ~/Desktop |
| 72 | + showfigfonts > figlet_fonts.txt |
| 73 | + ``` |
| 74 | + This command will save the list of available figlet fonts to a text file named `figlet_fonts.txt`. |
| 75 | + Outputting to a txt file is a handy way to be able to preview **all** of the fonts available to you as there is a lot of them and your terminal may not be able to display them all at once. |
| 76 | + I've also added the output as a page if you'd like to view it [all figlet fonts](content/blog-posts/2025-01-17-using-figlet-and-lolcat.md) |
| 77 | + |
| 78 | +3. **Test Figlet Output:** |
| 79 | + |
| 80 | + Run the following to test Figlet: |
| 81 | + ```bash |
| 82 | + figlet -f slant "Success" |
| 83 | + ``` |
| 84 | + |
| 85 | +4. **Combine Figlet with Lolcat:** |
| 86 | + |
| 87 | + Add some colour to your output: |
| 88 | + ```bash |
| 89 | + figlet -f slant "Success" | lolcat |
| 90 | + ``` |
| 91 | + You should see a colourful ASCII-styled message in your terminal. |
| 92 | + |
| 93 | +  |
| 94 | +--- |
| 95 | + |
| 96 | +## **Example Usage** |
| 97 | +Here are some examples to try: |
| 98 | + |
| 99 | +1. **Custom Welcome Message:** |
| 100 | + ```bash |
| 101 | + figlet -f big "Welcome" | lolcat |
| 102 | + ``` |
| 103 | + |
| 104 | +  |
| 105 | + |
| 106 | +2. **Dynamic Output:** |
| 107 | + Combine Figlet and Lolcat with other commands: |
| 108 | + ```bash |
| 109 | + echo "Hello, $(whoami)!" | figlet | lolcat |
| 110 | + ``` |
| 111 | + |
| 112 | +  |
| 113 | + |
| 114 | +## Trying Out Figlet and Lolcat together |
| 115 | + |
| 116 | +Now that you have Figlet working, let’s enhance it with Lolcat’s colourful output. |
| 117 | + |
| 118 | +1. **Basic Test**: |
| 119 | + ```bash |
| 120 | + figlet -f ansi_shadow "HI BREEZY" | lolcat |
| 121 | + ``` |
| 122 | + This will display a vibrant, rainbow-colored message. |
| 123 | + |
| 124 | +  |
| 125 | + |
| 126 | +2. **Lolcat Options Explained**: |
| 127 | + Lolcat comes with a variety of options to customise the colour output: |
| 128 | + |
| 129 | + - **`-a` (Animation)**: |
| 130 | + Enables animated colouring that cycles through colours over time. |
| 131 | + Example: |
| 132 | + ```bash |
| 133 | + figlet -f ansi_shadow "HI BREEZY" | lolcat -a |
| 134 | + ``` |
| 135 | +  |
| 136 | + |
| 137 | + - **`-d` (Delay)**: |
| 138 | + Sets the delay in milliseconds for animated frames when `-a` is enabled. |
| 139 | + Example: |
| 140 | + ```bash |
| 141 | + figlet -f ansi_shadow "HI BREEZY" | lolcat -a -d 5 |
| 142 | + ``` |
| 143 | +  |
| 144 | + |
| 145 | + - **`-F` (Frequency)**: |
| 146 | + Adjusts the rainbow frequency. Lower values create smoother gradients. |
| 147 | + Examples: |
| 148 | + ```bash |
| 149 | + figlet -f ansi_shadow "HI BREEZY" | lolcat -F 0.3 |
| 150 | + ``` |
| 151 | + ```bash |
| 152 | + figlet -f ansi_shadow "HI BREEZY" | lolcat -F 0.5 |
| 153 | + ``` |
| 154 | + ```bash |
| 155 | + figlet -f ansi_shadow "HI BREEZY" | lolcat -F 0.7 |
| 156 | + ``` |
| 157 | + |
| 158 | +  |
| 159 | + |
| 160 | + - **Without Options**: |
| 161 | + By default, `lolcat` applies a static rainbow gradient. |
| 162 | + Example: |
| 163 | + ```bash |
| 164 | + figlet -f ansi_shadow "HI BREEZY" | lolcat |
| 165 | + ``` |
| 166 | +  |
| 167 | + |
| 168 | +3. **Creative Uses**: |
| 169 | + - **Rainbow String**: |
| 170 | + ```bash |
| 171 | + echo "Hello, Breezy!" | lolcat |
| 172 | + ``` |
| 173 | + - **Animate Directory Listing**: |
| 174 | + ```bash |
| 175 | + ls -la | lolcat -a -d 10 |
| 176 | + ``` |
| 177 | + - **Rainbow File Output**: |
| 178 | + ```bash |
| 179 | + cat yourfile.txt | lolcat -a -d 3 |
| 180 | + ``` |
| 181 | + |
| 182 | +--- |
| 183 | + |
| 184 | +## Customising Your Terminal |
| 185 | + |
| 186 | +### **Using Figlet and Lolcat** |
| 187 | + |
| 188 | +Decide on the text you'd like to display, whether to use Lolcat, and which fonts and styles suit your preferences. For example, I chose the `ANSI Shadow` font and custom colours for my terminal setup. Here's how you can add your own customisation: |
| 189 | + |
| 190 | +1. Open your terminal configuration file (e.g., `.zshrc` or `.bashrc`). |
| 191 | +2. Add the following line at the very beginning to display your message every time you open the terminal: |
| 192 | + |
| 193 | + (can change the message, font and lolcat options to whatever you'd like) |
| 194 | + ```bash |
| 195 | + figlet -f ansi_shadow "HI BREEZY" | lolcat -F 0.3 |
| 196 | + ``` |
| 197 | +
|
| 198 | +3. Save the file and restart your terminal to see the magic in action. |
| 199 | +
|
| 200 | +Here’s an example of how it looks when I first open my terminal: |
| 201 | + |
| 202 | +
|
| 203 | +--- |
| 204 | +
|
| 205 | +### **Using Figlet with Custom Colours** |
| 206 | +
|
| 207 | +For a more personalised touch, you can use ANSI colour codes to apply specific colours to your Figlet output. Here’s how to preview and customise your terminal message with your favorite colours: |
| 208 | +
|
| 209 | +1. **Run the Following Script**: |
| 210 | + This script uses a set of predefined ANSI colours to apply vibrant hues to Figlet text, cycling through them line by line: |
| 211 | + ```bash |
| 212 | + # Define colors |
| 213 | + colors=( |
| 214 | + "\033[38;5;171m" |
| 215 | + "\033[38;5;135m" |
| 216 | + "\033[38;5;175m" |
| 217 | + "\033[38;5;141m" |
| 218 | + "\033[38;5;212m" |
| 219 | + ) |
| 220 | +
|
| 221 | + # Generate Figlet text with ANSI Shadow font |
| 222 | + figlet_text=$(figlet -f ansi_shadow "HI BREEZY") |
| 223 | +
|
| 224 | + # Split the Figlet text into lines (zsh-compatible) |
| 225 | + lines=("${(f)figlet_text}") |
| 226 | +
|
| 227 | + # Apply colors to each line and print |
| 228 | + for i in {1..${#lines[@]}}; do |
| 229 | + color=${colors[$(( (i - 1) % ${#colors[@]} + 1 ))]} # Cycle through colors |
| 230 | + echo -e "${color}${lines[i-1]}\033[0m" # Reset color at the end |
| 231 | + done |
| 232 | + ``` |
| 233 | +
|
| 234 | + Here's how the output will look: |
| 235 | +  |
| 236 | + |
| 237 | +2. **Customise It**: |
| 238 | + - Replace `ansi_shadow` with your preferred Figlet font. |
| 239 | + - Change the colours by updating the ANSI codes in the `colours` array. Use the colour chart below to pick your favorite shades. |
| 240 | + |
| 241 | +3. **Preview Colours**: |
| 242 | + Here’s an ANSI colour chart to help you choose: |
| 243 | +  |
| 244 | + |
| 245 | +4. **Enjoy Your Setup**: |
| 246 | + Save the script to a file or add it to your shell configuration to make your terminal display colourful, personalised messages every time it starts. |
0 commit comments