Skip to content

Instantly share code, notes, and snippets.

@thebaer
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebaer/68ca84d0f51e66f99da3 to your computer and use it in GitHub Desktop.
Save thebaer/68ca84d0f51e66f99da3 to your computer and use it in GitHub Desktop.
A little script for welcoming you to your newly-opened terminal. Targeted at Ubuntu.
#!/bin/bash
BLUE="\033[0;34m"
LBLUE="\033[1;34m"
GRAY="\033[1;30m"
NC="\033[00m"
spacing=" $GRAY█$NC "
case $(date +%u) in
1)
day=Monday
;;
2)
day=Tuesday
;;
3)
day=Wednesday
;;
4)
day=Thursday
;;
5)
day=Friday
;;
6)
day=Saturday
;;
7)
day=Sunday
;;
esac
ruptime=$(uptime | sed 's/.*up \([^,]*\), .*/\1/')
echo -e "$spacing"
echo -e "${spacing}Welcome, $USER"
echo -e "${spacing}$(date +'%m/%d/%Y') at $(date +'%I:%M %P')"
echo -e "${spacing}Today is $day"
echo -e "$spacing"
echo -e "${spacing}${LBLUE}Uptime :$NC $ruptime"
echo -en "${spacing}${LBLUE}Load :$NC "
cat /proc/loadavg | awk '{print $1 " " $2 " " $3}'
function updateip() {
ip=$(curl --silent http://what-is-my-ip.net/?text)
echo "$ip|$(iwgetid -r)" > .lastip
}
# Cache the last IP address, fetching the latest if wireless access point has
# changed.
if [ -e ".lastip" ]; then
lastip=$(cat .lastip)
savedip=$(echo $lastip | cut -d \| -f 1)
savedssid=$(echo $lastip | cut -d \| -f 2)
ssid=$(iwgetid -r)
if [ "$ssid" != "$savedssid" ]; then
updateip
else
ip=$savedip
fi
else
updateip
fi
echo -e "${spacing}${LBLUE}IP Address :$NC $ip"
# Get system updates
hasupdate=false
while read l; do
echo -e "${spacing}$l"
hasupdate=true
done </var/lib/update-notifier/updates-available
if [ !$hasupdate ]; then
echo -e "${spacing}There are no updates available."
echo -e "$spacing"
fi
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment