Skip to content

Instantly share code, notes, and snippets.

@TheCrazyGM
Created June 16, 2025 12:51
Show Gist options
  • Select an option

  • Save TheCrazyGM/eadff1d2603d2bc6e50ee32c0b0df452 to your computer and use it in GitHub Desktop.

Select an option

Save TheCrazyGM/eadff1d2603d2bc6e50ee32c0b0df452 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the operating system name and version
os=$(lsb_release -ds)
# Get the kernel version
kv=$(uname -r)
# Get the name of the current shell
sh=${SHELL##*/}
# Initialize the user interface variable to 'unknown'
ui='unknown'
# Determine the user interface (desktop environment or window manager)
if [ -n "${DE}" ]; then
ui="${DE}" # If DE variable is set, use it
elif [ -n "${WM}" ]; then
ui="${WM}" # If WM variable is set, use it
elif [ -n "${XDG_CURRENT_DESKTOP}" ]; then
ui="${XDG_CURRENT_DESKTOP}" # Use XDG_CURRENT_DESKTOP if set
elif [ -n "${DESKTOP_SESSION}" ]; then
ui="${DESKTOP_SESSION}" # Use DESKTOP_SESSION if set
elif [ -n "${rcwm}" ]; then
ui="${rcwm}" # Use rcwm if set
elif [ -n "${XDG_SESSION_TYPE}" ]; then
ui="${XDG_SESSION_TYPE}" # Use XDG_SESSION_TYPE if set
fi
# Get the base name of the user interface variable
ui="$(basename "${ui}")"
# Function to set text color based on input argument
color() {
case "$1" in
red) printf '\033[1;31m' ;; # Set color to red
green) printf '\033[1;32m' ;; # Set color to green
yellow) printf '\033[1;33m' ;; # Set color to yellow
blue) printf '\033[1;34m' ;; # Set color to blue
magenta) printf '\033[1;35m' ;; # Set color to magenta
cyan) printf '\033[1;36m' ;; # Set color to cyan
gray) printf '\033[1;30m' ;; # Set color to gray
white) printf '\033[1;37m' ;; # Set color to white
reset) printf '\033[0m' ;; # Reset color to default
esac
}
# Initialize output variable with a newline
output="\n"
# Append formatted OS information to output
output+=$(printf "%b" "$(color red) os - $(color reset)$os\n")"\n"
# Append formatted kernel version to output
output+=$(printf "%b" "$(color yellow) kr - $(color reset)$kv\n")"\n"
# Append formatted shell information to output
output+=$(printf "%b" "$(color green) sh - $(color reset)$sh\n")"\n"
# Append formatted window manager information to output
output+=$(printf "%b" "$(color blue) wm - $(color reset)$ui\n")"\n\n"
# Convert output to lowercase efficiently
output=$(tr '[:upper:]' '[:lower:]' <<< "$output")
# Print the final output
printf "%b" "$output"
# Print a modern, colorful bar using solid block characters (optimized)
for color in red green yellow blue magenta cyan gray white; do
printf "%s\u2588\u2588 %s" "$(color "$color")" "$(color reset)"
done
printf "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment