Skip to content

Instantly share code, notes, and snippets.

@Trshant
Created September 1, 2023 19:39
Show Gist options
  • Save Trshant/cae5e6dc1865c02d52e28ba0bd7e4559 to your computer and use it in GitHub Desktop.
Save Trshant/cae5e6dc1865c02d52e28ba0bd7e4559 to your computer and use it in GitHub Desktop.
This is something else i have made to make bash scripting easier. This is a library that one can import to use in making colored prompts. Colors in the terminal are easy once you know how, but i just thought it might be a good idea to have a library just in case!
function prompt/color(){
local RED="\e[31m"
local GREEN="\e[32m"
local YELLOW="\e[33m"
local BLUE="\e[34m"
local INPUTCOLOR=$1
eval "COLOR="\${$INPUTCOLOR}
local TEXT=$2
local ENDCOLOR="\e[0m"
echo -e "${COLOR}${TEXT}${ENDCOLOR}"
}
function prompt/warning(){
prompt/color RED "$1"
}
function prompt/info(){
prompt/color YELLOW "$1"
}
function prompt/success(){
prompt/color GREEN "$1"
}
function prompt/notification(){
prompt/color BLUE "$1"
}
source ./prompt.sh
prompt/warning "this is a warning"
prompt/info "this is information"
prompt/success "this is a success thing"
prompt/notification "this is a notification"
echo "checking that the endcolor is working"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment