#!/usr/bin/env bash # Join all arguments into one string and append the reset code &r tmp="$*&r" # Replace Minecraft-style color codes with ANSI escape sequences tmp="${tmp//&0/$'\e[0;30m'}" tmp="${tmp//&1/$'\e[0;34m'}" tmp="${tmp//&2/$'\e[0;32m'}" tmp="${tmp//&3/$'\e[0;36m'}" tmp="${tmp//&4/$'\e[0;31m'}" tmp="${tmp//&5/$'\e[0;35m'}" tmp="${tmp//&6/$'\e[0;33m'}" tmp="${tmp//&7/$'\e[0;37m'}" tmp="${tmp//&8/$'\e[1;30m'}" tmp="${tmp//&9/$'\e[1;34m'}" tmp="${tmp//&a/$'\e[1;32m'}" tmp="${tmp//&b/$'\e[1;36m'}" tmp="${tmp//&c/$'\e[1;31m'}" tmp="${tmp//&d/$'\e[1;35m'}" tmp="${tmp//&e/$'\e[1;33m'}" tmp="${tmp//&f/$'\e[1;37m'}" tmp="${tmp//&r/$'\e[0m'}" # Replace &n with a literal newline newline=$'\n' tmp="${tmp//&n/$newline}" # Use -e to ensure the shell interprets the escape characters echo -e "$tmp"