This page looks best with JavaScript enabled

I Learn How To Make Bash Flip Tables When I Break Things

 ·   ·  ☕ 1 min read

Lets take a look at how to customize a bash shell. We’ll be making our shell print a table flip whenever the last command failed. In order to customize your prompt you can overwrite the PS1 environment variable.

To see what your current prompt is set to you can run echo "$PS1"

The table flip script looks like this:

1
2
3
4
5
6
7
table_flip() {
  if [[ "$?" == "0" ]]; then
    echo ""
  else
    echo "(╯°□°)╯︵ ┻━┻"
  fi
}

Here is a tool that can help you customize your prompt more easily: http://ezprompt.net/

The ArchLinux wiki goes into much more detail about prompt customization: https://wiki.archlinux.org/index.php/Bash/Prompt_customization#Bash_escape_sequences

Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u


Sam Wronski
WRITTEN BY
Sam Wronski
Maker of things, currently helping build cloud things @ Microsoft. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!