-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgiggiobash.rc
More file actions
79 lines (77 loc) · 2.81 KB
/
giggiobash.rc
File metadata and controls
79 lines (77 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
## "Bashrc_giggione"
## @TzuLuX @arkanet
##
## Make a copy of .bashrc and edit older file adding this lines at the tail
## at this point you can see your new motd with "source .bashrc"
##
##
## ------------[ADD_ME]-------------
# Sequenze escape dei colori
C_WHITE='\033[1;37m'
C_LIGHTGRAY='\033[0;37m'
C_GRAY='\033[1;30m'
C_BLACK='\033[0;30m'
C_RED='\033[0;31m'
C_LIGHTRED='\033[1;31m'
C_GREEN='\033[0;32m'
C_LIGHTGREEN='\033[1;32m'
C_BROWN='\033[0;33m'
C_YELLOW='\033[1;33m'
C_BLUE='\033[0;34m'
C_LIGHTBLUE='\033[1;34m'
C_PURPLE='\033[0;35m'
C_PINK='\033[1;35m'
C_CYAN='\033[0;36m'
C_LIGHTCYAN='\033[1;36m'
C_DEFAULT='\033[0m'
## -------------------------
UserName="${USER}"
host_name="${HOSTNAME}"
distro_ver="$( lsb_release -d | cut -f2 )"
up_time="$( uptime | cut -d ',' -f1 | cut -d ' ' -f4-6 )"
CPU_Arch="$(uname -m)"
ip4_eth="$(ip -4 a s | while read ipv4; do echo -e "${ipv4}" | grep -v '127.0.0.1' | sed 's/\// /g' | awk '/inet / {print $2}' | tr -s '\n' ' '; done)"
ip4_wan="$(curl --silent http://www.tzunami.it/IP.php)"
ip6_lan="$(ip -6 a s | while read ipv6; do echo -e "${ipv6}" | grep -v "host" | grep "/64" | grep -v "fe80" | sed 's/\// /g' | awk '/global/{print $2}' | tr -s '\n' ' '; done)"
## ----------------------------------------------------------
disk_values="$(df -h | grep "rootfs" | awk '{print $2, $4, $5}')"
disk_size="$(echo ${disk_values} | awk '{print $1}')"
disk_avail="$(echo ${disk_values} | awk '{print $2}')"
disk_percentage=$(echo ${disk_values} | awk '{print $3}' | cut -d "%" -f1)
case ${disk_percentage} in
[0-25]*)
C_VAR=${C_LIGHTGREEN} # From 0% to 25%
;;
[26-50]*)
C_VAR=${C_GREEN} # From 26% to 50%
;;
[51-75]*)
C_VAR=${C_YELLOW} # From 51% to 75%
;;
[76-90]*)
C_VAR=${C_BROWN} # From 76% to 90%
;;
9[1-8])
C_VAR=${C_LIGHTRED} # From 91% to 98%
;;
99)
C_VAR=${C_RED} # 99%
;;
*)
C_VAR=${C_GRAY} # I seem to be running with an nonexistent amount of disk space..."
;;
esac
## ----------------------------------------------------------
echo
echo -e " Welcome user:[${C_WHITE} ${UserName} ${C_DEFAULT}]"
echo -e " You are on machine:[${C_RED} ${host_name} ${C_DEFAULT}]"
echo -e " CPU architecture:[${C_BROWN} ${CPU_Arch} ${C_DEFAULT}]"
echo -e " Running Distro:[${C_GREEN} ${distro_ver} ${C_DEFAULT}]"
echo -e " With UpTime:[${C_CYAN} ${up_time} ${C_DEFAULT}]"
echo -e " Disk space avail:[${C_VAR} ${disk_avail} ${C_DEFAULT}(${C_VAR}${disk_percentage}%${C_DEFAULT}) of ${C_GRAY}${disk_size} ${C_DEFAULT}]"
echo -e "Your private IPv4 is:[${C_YELLOW} ${ip4_eth}${C_DEFAULT}]"
echo -e " Your public IPv4 is:[${C_YELLOW} ${ip4_wan} ${C_DEFAULT}]"
echo -e "your IPv6 address is:[${C_BLUE} ${ip6_lan}${C_DEFAULT}]"
tput sgr0 # Reset attributes.
echo
echo "Ranking Connections"; last | head -n -2 | awk '{ print $1 }' | sort -n | uniq -c | sort -nr