Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed all issiues #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions namaskar.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
#!/bin/bash

# Function to calculate percentage
get_percentage() {
used=$1
total=$2
awk -v used="$used" -v total="$total" 'BEGIN { printf("%.2f%%", (used / total) * 100) }'
}

# Get memory and swap usage details
memory_usage=$(free -h --si | awk '/^Mem/ {print $3 " / " $2}')
swap_usage=$(free -h --si | awk '/^Swap/ {print $3 " / " $2}')

# Calculate percentage for memory
memory_used=$(free --si | awk '/^Mem/ {print $3}')
memory_total=$(free --si | awk '/^Mem/ {print $2}')
memory_percentage=$(get_percentage "$memory_used" "$memory_total")

# Calculate percentage for swap
swap_used=$(free --si | awk '/^Swap/ {print $3}')
swap_total=$(free --si | awk '/^Swap/ {print $2}')
swap_percentage=$(get_percentage "$swap_used" "$swap_total")

host=$(uname -n)
user=$(whoami)
shell=$(echo $SHELL)
kernel="$(uname -r)"
shell="$(basename "${SHELL}")"
os="$(uname -s)"
uptime="$(uptime -p)"
shell=$(basename "$SHELL")
kernel=$(uname -r)
os=$(uname -s)
uptime=$(uptime -p)

echo ""
c1=$(echo -e "\e[42m \e[0m")
c2=$(echo -e "\e[41m \e[0m")
c3=$(echo -e "\e[43m \e[0m")
c4=$(echo -e "\e[44m \e[0m")
c5=$(echo -e "\e[45m \e[0m")
c6=$(echo -e "\e[46m \e[0m")

cat <<EOF

Expand All @@ -19,7 +43,9 @@ ${c2} │ ┌─┼─┐ host : ${host}
${c3} │ │ │ │ user : ${user}
${c4} └─┼─┘ │ kernel : ${kernel}
${c5} └───┘ shell : ${shell}
${c5} └───┘ ram : ${memory_percentage} (${memory_usage})
${c5} └───┘ swap : ${swap_percentage} (${swap_usage})
${c6} └───┘ uptime : ${uptime}

 ${uptime}

EOF