Advertisement
Guest User

fetch

a guest
Oct 26th, 2020
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.31 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. os_name=$(cat /etc/os-release | grep "ID" | head -n 1)
  4. version_no=$(cat /etc/os-release | grep "VERSION_ID" | head -n 1)
  5. os_name_ver="${os_name:3} ${version_no:12:-1}"
  6.  
  7. kern=$(uname -r)
  8.  
  9. shell_prefixed="$SHELL"
  10. shell_name=${shell_prefixed#/usr/bin/}
  11.  
  12. script_ppid=$(ps -p $PPID -o ppid --no-headers)
  13. term=$(ps -p $script_ppid -o comm --no-headers)
  14.  
  15. wm_icon=""
  16.  
  17. wm="$XDG_CURRENT_DESKTOP"
  18. if [[ -z "$wm" ]];then
  19.     wm="$DESKTOP_SESSION"
  20.     wm_icon="﬿"
  21. fi
  22.  
  23. mem_size=$(free -h --mega | head -n 2| tail -n 1)
  24. echo $mem_size > /tmp/memm
  25. mem_used=$(cut -d " " -f 3 /tmp/memm)
  26. mem_tot=$(cut -d " " -f 2 /tmp/memm)
  27. mem_use_tot="${mem_used}/${mem_tot}"
  28.  
  29. cpu_info=$(lscpu | grep "Model name")
  30. cpu_name=$(echo ${cpu_info:11} | xargs)
  31.  
  32. host_mach=$(cat /sys/devices/virtual/dmi/id/product_name)
  33.  
  34. user_host="$(tput setaf 6)$(tput bold)$(whoami)$(tput setaf 3)$(tput setaf 6)\
  35. $(hostname)$(tput sgr0)"
  36.  
  37. print_info() {
  38.     for j in {1..8}
  39.         do
  40.             echo -ne "\e[0;3$1m \e[0m"
  41.         done
  42.     echo -e "  $(tput setaf 3)$2  $(tput sgr0)$3"
  43.  
  44. }
  45.  
  46. echo $user_host
  47.  
  48. print_info 0"$os_name_ver"
  49. print_info 1"$kern"
  50. print_info 2"$shell_name"
  51. print_info 3"$term"
  52. print_info 4 "$wm_icon" "$wm"
  53. print_info 5"$mem_use_tot"
  54. print_info 6"$cpu_name"
  55. print_info 7"$host_mach"
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement