Skip to content

Instantly share code, notes, and snippets.

@loneicewolf
Last active November 21, 2022 11:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loneicewolf/bff76d8d0809120525a65c3621b81be8 to your computer and use it in GitHub Desktop.
Save loneicewolf/bff76d8d0809120525a65c3621b81be8 to your computer and use it in GitHub Desktop.
colors, effects, message box, popups, etc - in bash
## edit: this was only called "colors in bash" but I renamed it to include more "general" or "overall" effects,
## such as; popups(zenity, notify-send, ..) and (soon coming!) ncurses, etc.
# might be some errors (not only grammar)
# red=31
# green=32
# blue=34
# yellow=33
# cyan=36
# pink=35
## to use printf DO \n AT END
m="hello" && for i in {31,32,34,33,36,35}; do printf "\e["$i"m$m\e[00m\n"; done
m="hello" && for i in {31,32,34,33,36,35}; do echo -e "\e["$i"m$m\e[00m"; done
# hello
# ...
# hello
## all in diff colors.
@loneicewolf
Copy link
Author

m="hello"  && for i in {31,32,34,33,36,35}; do printf "\t # \e["$i"m$m\e[00m\n"; done

image

@loneicewolf
Copy link
Author

note: not mine, I took it from CERNs spectre/meltdown check bash script

ALERT(){
  case "$1" in
    R) col="\033[101m\033[30m";;
    G) col="\033[102m\033[30m";;
    Y) col="\033[103m\033[30m";;
    B) col="\033[104m\033[30m";;
    *) col="";;
  esac
  /bin/echo -ne "$col $2 \033[0m"
  [ -n "$3" ] && /bin/echo -n " ($3)"
  /bin/echo
}
ALERT "G" "[+] something went good somewhere.."
ALERT "R" "[-] something went terribly wrong somewhere.. hopefully not here..."

image

@loneicewolf
Copy link
Author

m="hello"  && for i in {1,2,4,3,6,5}; do printf "\t# \e["4$i"m$m\e[00m\n"; done

image

@loneicewolf
Copy link
Author

zenity --warning --text "WARNING"

image

@loneicewolf
Copy link
Author

in-terminal box/menu with whiptail

whiptail --msgbox "MSGBOX TEXT" 10 25

image

@loneicewolf
Copy link
Author

Okay, but what about pictures?

text is good, but.. not very "nice" or "fun" to look at, would be better if we could use some nice picture (as well) as the text. Why limit ourselves? :)

first download your favo picture. Which might be, you know - a wallpaper, an actual icon, emoji, or a gif. (if a gif, screenshot where you want - and save it as a .ico) (in fact, save all pictures/images/icons as just that. Icons (.ico) else you will get a ⚠️ symbol instead

#                ~~~~~icon to display~~~~~      ~~~~~message to display~~~~~
notify-send -i /path/to/your/favorite/image.ico   "Hello world!"

it will not only (as you probably already guessed) display text "hello world!" but it will also display that icon (think of a fun thing like when you boot into the system and you are presented with a message saying "welcome" and a emoji with sunglasses on, instead of just a boring text.)

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