Skip to content

Instantly share code, notes, and snippets.

@emcek
Last active August 29, 2015 14:15
Show Gist options
  • Save emcek/6e3faa75d06553bb745b to your computer and use it in GitHub Desktop.
Save emcek/6e3faa75d06553bb745b to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# SIV : System Information Viewer
#
# Author : Saikat Basak (saikat@saikatbasak.com)
#
# **** License ****
#
# The software is distributed under "THE BEER-WARE LICENSE" (Revision 42)
# The Beer-ware license was written by Poul-Henning Kamp. <phk@FreeBSD.ORG>
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return.
# ----------------------------------------------------------------------------
#
# **** variable declaration ****
declaration(){
# **** color ****
c0='[0m'
c1='[1;31m' # RED
c2='[1;32m' # GREEN
c3='[1;33m' # YELLOW
c4='[1;34m' # BLUE
c5='[1;35m' # PURPLE
c6='[1;36m' # CYAN
c7='[1;37m' # GRAY
# **** info ****
OS=$(uname -o)
HOST=$(hostname)
USER=$(whoami)
UPTIME=$(</proc/uptime)
UPTIME=${UPTIME//.*}
SECS=$((${UPTIME}%60))
MINS=$((${UPTIME}/60%60))
HOURS=$((${UPTIME}/3600%24))
DAYS=$((${UPTIME}/86400))
UPTIME="${MINS}m ${SECS}s"
if [ "${HOURS}" -ne "0" ]; then
UPTIME="${HOURS}h ${UPTIME}"
fi
if [ "${DAYS}" -ne "0" ]; then
UPTIME="${DAYS}d ${UPTIME}"
fi
KERNEL=$(uname -r)
CPU=$(awk 'BEGIN{FS=":"} /model name/ { gsub(/ +/," ",$2); gsub(/^ /,"",$2); gsub(/\(R\)|\(TM\)/,"",$2); print $2; exit }' /proc/cpuinfo);
MEM_INFO=$(</proc/meminfo)
MEM_INFO=$(echo $(echo $(MEM_INFO=${MEM_INFO// /}; echo ${MEM_INFO//kB/})))
for m in $MEM_INFO; do
if [[ ${m//:*} = MemTotal ]]; then
MEMTOTAL=${m//*:}
fi
if [[ ${m//:*} = MemFree ]]; then
MEMFREE=${m//*:}
fi
if [[ ${m//:*} = Buffers ]]; then
MEMBUFFER=${m//*:}
fi
if [[ ${m//:*} = Cached ]]; then
MEMCACHED=${m//*:}
fi
done
USEDMEM="$((($MEMTOTAL - $MEMFREE - $MEMBUFFER - $MEMCACHED) / 1024))"
TOTALMEM="$(($MEMTOTAL / 1024))"
MEM_DISPLAY="$USEDMEM / $TOTALMEM MB"
ROOT_USED=$(df -h / | awk 'NR==2 {print $3}')
ROOT_TOT=$(df -h / | awk 'NR==2 {print $2}')
ROOT_PER=$(df -h / | awk 'NR==2 {print $5}')
ROOT_DISPLAY="$ROOT_USED / $ROOT_TOT ($ROOT_PER)"
}
# **** lame quotes ****
lame_quote_gentoo(){
declare -a arr_gentoo=("Its -O3 the letter, not -03 the number." "Compiling from scratch is really hyped, what makes Gentoo cool is the technical merits like rc-updating and USE flags." "Gentoo does help stop programmers from being lazy, so they write completely airtight code. That can only be a good thing, whichever way you look at it." "What other gnu/linux will let you have a vector optimized wordprocessor?" "Debian is easy to keep up to date. That's because they don't update it." "The performance gained by CFLAGS on x86 is minimal at best -- largely because the machines are still basically overclocked 386's at their core." "HOLY COW I'M TOTALLY GOING SO FAST OH F***!!" "Anyone ever wondered how larry can be a cow!" "If it moves compile it." "I use Gentoo because I'm a speed freak - I can't stand the thought that some of my packages might not be running as fast as they could be.")
i=$(expr $RANDOM % 10)
QUOTE_DISPLAY="${arr_gentoo[$i]}"
}
lame_quote_star_wars(){
declare -a arr_star_wars=("Look, good against remotes is one thing, good against the living, that's something else." "Aren't you a little short for a stormtrooper?" "The Force is strong with this one." "I find your lack of faith disturbing." "May the Force be with you." "I'm Luke Skywalker, I'm here to rescue you." "Boring conversation anyway. Luke, we're gonna have company!" "You're all clear, kid! Now let's blow this thing and go home!" "You've never heard of the Millennium Falcon? ... It's the ship that made the Kessel run in less than 12 parsecs." "I am your Father..." )
i=$(expr $RANDOM % 10)
QUOTE_DISPLAY="${arr_star_wars[$i]}"
}
lame_quote_vader(){
declare -a arr_vader=("I find your lack of faith disturbing." "Luke, I am your father!" "I sense something, a presence I've not felt since......." "You should not have come back!" "The ability to destroy a planet is insignificant next to the power of the force." "Just for once, let me look at your face with my own eyes." "Obi-Wan has taught you well." "He will join us or die, my master." "You have controlled your fear. Now, release your anger. Only your hatred can destroy me." "When I left you I was but the learner. Now I am the master.")
i=$(expr $RANDOM % 10)
QUOTE_DISPLAY="${arr_vader[$i]}"
}
lame_quote_star_trek(){
declare -a arr_star_trek=("Fascinating." "Do you want to tell me what's bothering you or would you like to break some more furniture?" "Rumors of my assimilation are greatly exaggerated." "Spock, I do not know too much about these little Tribbles yet, but there is one thing that I have discovered. I like them ... better than I like you." "I would be delighted to offer any advice I can on understanding women. When I have some, I'll let you know." "Do that thing we just talked about." "What does god need with a starship?" "Our neural pathways have become accustomed to your sensory input patterns." "Please, Captain, not in front of the Klingons." "KHAAANNNN!")
i=$(expr $RANDOM % 10)
QUOTE_DISPLAY="${arr_star_trek[$i]}"
}
lame_quote_mortal_kombat(){
declare -a arr_mk=("Vengeance will be mine!" "Finish Him!" "Your soul is mine!" "Fatality." "Every man is responsible for his own destiny." "Let the Mortal Kombat begin." "Flawless victory." "Liu Kang Wins!" "Sonya Wins!" "Scorpion and Sub-Zero. Deadliest of enemies but slaves under my power.")
i=$(expr $RANDOM % 10)
QUOTE_DISPLAY="${arr_mk[$i]}"
}
lame_quote_royal(){
declare -a arr_royal=("The interpretation of dreams is the royal road to a knowledge of the unconscious activities of the mind." "The royal road to a man's heart is to talk to him about the things he treasures most." "In the past, people were born royal. Nowadays, royalty comes from what you do." "There was a knight came riding by.. In early spring, when the roads were dry." "A true knight is fuller of bravery in the midst, than in the beginning of danger." "I have played a boxer, a cowboy, a knight, a prince, an elf and a pirate. I am so glad to have done all of that already." "Heroism is endurance for one moment more." "The greatest height of heroism to which an individual, like a people, can attain is to know how to face ridicule." "Faith is the heroism of the intellect." "True heroism is remarkably sober, very undramatic.")
i=$(expr $RANDOM % 10)
QUOTE_DISPLAY="${arr_royal[$i]}"
}
lame_quote_batman(){
declare -a arr_batman=("How about a magic trick?" "It's simple. We, uh, kill the Batman." "If you're good at something, never do it for free." "Some men just want to watch the world burn." "Going to see your wife? You love her?" "There won't be any fireworks!" "What were you trying to prove? That deep down, everyone's as ugly as you?! You're alone." "But the Joker cannot win. Gotham needs its true hero." "Why So Serious?" "I'm an agent of chaos.")
i=$(expr $RANDOM % 10)
QUOTE_DISPLAY="${arr_batman[$i]}"
}
# **** display ****
display_gentoo(){
echo -e "\\e${c5} ."
echo " .siv. d\@b"
echo " .d@@@@@@b. .cd@@b. .d@@b. d@@@@@@@@@@@b .d@@b. .d@@b."
echo " @@@@( )@@@b d@@( )@@@. d@@@@@@@b Q@@@@@@@P@@@P.@@@@@@@b. .@@@@@@@b."
echo " Q@@@@@@@@@@B@@@@@@@@P\" d@@@PQ@@@@b. @@@@. .BOOB' \`@@@ .@@@P' \`@@@"
echo " \"@@@@@@@P Q@@@@@@@b d@@@P Q@@@@b @@@@b @@@@b..d@@@ @@@@b..d@@@"
echo " d@@@@@@P\" \"@@@@@@@@ Q@@@ Q@@@@ @@@@@ \`Q@@@@@@@P \`Q@@@@@@@P"
echo " @@@@@@@P \`\"\"\"\"\" \"\" \"\" Q@@@P \"Q@@@P\" \"Q@@@P\""
echo " \`Q@@P\" \"\"\""
echo -e "\\e${c0}"
echo -e "\\e${c4}> \\e${c5}OS: \\e${c4}${OS}"
echo -e "\\e${c4}> \\e${c5}Hostname: \\e${c4}${HOST}"
echo -e "\\e${c4}> \\e${c5}User: \\e${c4}${USER}"
echo -e "\\e${c4}> \\e${c5}Uptime: \\e${c4}${UPTIME}"
echo -e "\\e${c4}> \\e${c5}Kernel: \\e${c4}${KERNEL}"
echo -e "\\e${c4}> \\e${c5}Shell: \\e${c4}${SHELL}"
echo -e "\\e${c4}> \\e${c5}CPU: \\e${c4}${CPU}"
echo -e "\\e${c4}> \\e${c5}RAM: \\e${c3}${MEM_DISPLAY}"
echo -e "\\e${c4}> \\e${c5}Root: \\e${c4}${ROOT_DISPLAY}"
echo ""
echo -e "\t\\e${c4}=>>>>\\e${c5} Lame Quote \\e${c4}<<<<="
echo -e "\\e${c0}"
echo -e "\\e${c4}> \\e${c3}${QUOTE_DISPLAY}\\e${c0}\n"
}
display_star_wars(){
echo -e "\\e${c3} . . ."
echo -e " . o88888888888888 d88b . 8888888b. . ."
echo -e " . . Y88<\"\"\"\"888\"\"\"\" j8PY8i 888 )88 ."
echo -e " Y8b. 888 ,8P Y8, 88888888' ."
echo -e "_________________>88b 888 88888888 888 Y8b_________________"
echo -e ":::::::::88888888888P 888 d8P Y8b 888 Y888888::::::::::::"
echo -e ":::::::::( )::::::::::::"
echo -e ":::::::::Y8b d88b d8P d88b . 8888888b. o88888888::::::::::::"
echo -e "\"\"\"\"\"\"\"\"\"\"88ij8888ij88' j8PY8i 888 )88 Y88<\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\""
echo -e " \"8888PY8888' ,8P Y8, 88888888' Y8b. . ."
echo -e " . Y88P Y88P 88888888 888 Y8b_____>88b ."
echo -e " . . Y8' \"8P d8P Y8b 888 Y888888888P ."
echo -e "\\e${c0}"
echo -e "\\e${c6}> \\e${c1}OS: \\e${c6}${OS}"
echo -e "\\e${c6}> \\e${c1}Hostname: \\e${c6}${HOST}"
echo -e "\\e${c6}> \\e${c1}User: \\e${c6}${USER}"
echo -e "\\e${c6}> \\e${c1}Uptime: \\e${c6}${UPTIME}"
echo -e "\\e${c6}> \\e${c1}Kernel: \\e${c6}${KERNEL}"
echo -e "\\e${c6}> \\e${c1}Shell: \\e${c6}${SHELL}"
echo -e "\\e${c6}> \\e${c1}CPU: \\e${c6}${CPU}"
echo -e "\\e${c6}> \\e${c1}RAM: \\e${c3}${MEM_DISPLAY}"
echo -e "\\e${c6}> \\e${c1}Root: \\e${c6}${ROOT_DISPLAY}"
echo ""
echo -e "\t\\e${c6}=>>>>\\e${c1} Lame Quote \\e${c6}<<<<="
echo -e "\\e${c0}"
echo -e "\\e${c6}> \\e${c3}${QUOTE_DISPLAY}\\e${c0}\n"
}
display_star_trek(){
echo -e "\t\\e${c3} ."
echo -e "\t\\e${c3} .#."
echo -e "\t\\e${c3} .###."
echo -e "\t\\e${c3} .#####."
echo -e "\t\\e${c6} ***\\e${c3}.#######.\\e${c6}***"
echo -e "\t\\e${c6} *******\\e${c3}.#########.\\e${c6}*******"
echo -e "\t\\e${c6} ********\\e${c3}.###########.\\e${c6}********"
echo -e "\t\\e${c6}********\\e${c3}.#############.\\e${c6}********"
echo -e "\t\\e${c6}*******\\e${c3}.######'\\e${c6}***\\e${c3}\`####.\\e${c6}*******"
echo -e "\t\\e${c6}******\\e${c3}.####'\\e${c6}*********\\e${c3}\`##.\\e${c6}******"
echo -e "\t\\e${c6} ****\\e${c3}.###'\\e${c6}*************\\e${c3}\`#.\\e${c6}****"
echo -e "\t\\e${c6} *\\e${c3}.##'\\e${c6}*****************\\e${c3}\`.\\e${c6}*"
echo -e "\t\\e${c3} .#' \\e${c6}*************** \\e${c3}."
echo -e "\t\\e${c3} ."
echo -e "\t\\e${c0}"
echo -e "\\e${c6}> \\e${c7}OS: \\e${c6}${OS}"
echo -e "\\e${c6}> \\e${c7}Hostname: \\e${c6}${HOST}"
echo -e "\\e${c6}> \\e${c7}User: \\e${c6}${USER}"
echo -e "\\e${c6}> \\e${c7}Uptime: \\e${c6}${UPTIME}"
echo -e "\\e${c6}> \\e${c7}Kernel: \\e${c6}${KERNEL}"
echo -e "\\e${c6}> \\e${c7}Shell: \\e${c6}${SHELL}"
echo -e "\\e${c6}> \\e${c7}CPU: \\e${c6}${CPU}"
echo -e "\\e${c6}> \\e${c7}RAM: \\e${c3}${MEM_DISPLAY}"
echo -e "\\e${c6}> \\e${c7}Root: \\e${c6}${ROOT_DISPLAY}"
echo ""
echo -e "\t\\e${c6}=>>>>\\e${c7} Lame Quote \\e${c6}<<<<="
echo -e "\\e${c0}"
echo -e "\\e${c6}> \\e${c3}${QUOTE_DISPLAY}\\e${c0}\n"
}
display_vader(){
echo -e "\\e${c6} _________________________________ "
echo -e "\\e${c6} |#############;;##################|\t\\e${c6} \\e${c1} OS: \\e${c6}$OS"
echo -e "\\e${c6} |###########'~||~~~\`\`#############|\t\\e${c6} \\e${c1} Hostname: \\e${c6}$HOST"
echo -e "\\e${c6} |########' .'# o\`###########|\t\\e${c6} \\e${c1} User: \\e${c6}$USER"
echo -e "\\e${c6} |#######' oo | |o o ##########|\t\\e${c6} \\e${c1} Uptime: \\e${c6}$UPTIME"
echo -e "\\e${c6} |####### 8 .'.' 8 o #########|\t\\e${c6} \\e${c1} Kernel: \\e${c6}$KERNEL"
echo -e "\\e${c6} |####### 8 | | 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment