From 75b695396f9b5ebe50be1ed48f168069cf4e4a17 Mon Sep 17 00:00:00 2001 From: q3aql Date: Fri, 15 Apr 2022 14:25:59 +0200 Subject: [PATCH] Dotfiles config update (2022-04-15) --- .bashrc | 17 +++++++++-------- .zshrc | 51 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 50 insertions(+), 18 deletions(-) diff --git a/.bashrc b/.bashrc index 6dca9cf..8d54109 100644 --- a/.bashrc +++ b/.bashrc @@ -149,12 +149,13 @@ alias ll='ls -l' alias la='ls -A' alias l='ls -CF' +# Load terminal echo "" echo -e -n "\e[32m# Preparing to start \e[0m\e[35mbash\e[0m \e[32mshell...\e[0m" #os_system="Devuan 4" os_system=$(lsb_release -d 2> /dev/null | tr -s " " | cut -d ":" -f 2) if [ -z "${os_system}" ] ; then - os_system="Unknown" + os_system=$(uname -o) else os_system=$(echo ${os_system}) fi @@ -182,14 +183,14 @@ elif [ -f /usr/bin/lscpu ] ; then else cpu_model="Unknown" fi -if [ -f /usr/bin/lsmem ] ; then - mem_total=$(lsmem | grep "Total online memory:" | tr -s " " | cut -d ":" -f 2) - mem_total=$(echo ${mem_total}) -elif [ -f /proc/meminfo ] ; then +if [ -f /proc/meminfo ] ; then mem_total_kb=$(cat /proc/meminfo | grep -i "memtotal" | tr -s " " | cut -d ":" -f 2) - mem_total_kb_num=$(echo ${mem_total_kb} | cut -d " " -f 1) - mem_total_gb=$(expr ${mem_total_kb_num} / 1024 / 1024) - mem_total=$(echo ${mem_total_gb}) + mem_total_kb_num=$(echo ${mem_total_kb} | tr -s " " | cut -d " " -f 1) + mem_total_gb=$(expr ${mem_total_kb_num} / 1000 / 1000) + mem_total=$(echo ${mem_total_gb}G) +elif [ -f /usr/bin/lsmem ] ; then + mem_total=$(lsmem | grep -i "total online memory:" | tr -s " " | cut -d ":" -f 2) + mem_total=$(echo ${mem_total}) else mem_total="Unknown" fi diff --git a/.zshrc b/.zshrc index 998d1db..d96048c 100644 --- a/.zshrc +++ b/.zshrc @@ -232,28 +232,59 @@ fi # some more ls aliases alias grep='grep --color=auto' -alias cat='batcat --style=plain --paging=never' -alias ls='exa --group-directories-first' -alias tree='exa -T' +if [ -f /usr/bin/batcat ] ; then + alias cat='batcat --style=plain --paging=never' +elif [ -f /usr/bin/bat ] ; then + alias cat='bat --style=plain --paging=never' +fi +if [ -f /usr/bin/exa ] ; then + alias ls='exa --group-directories-first' + alias tree='exa -T' +else + alias ls="ls --color=auto" +fi alias ll='ls -l' alias la='ls -A' alias l='ls -CF' +# Load terminal +echo "" +echo -e -n "\e[32m# Preparing to start \e[0m\e[35mzsh\e[0m \e[32mshell...\e[0m" os_system=$(uname -o) kernel=$(uname -r) -uptime=$(uptime | tr -s " " | cut -d "," -f 1) -uptime=$(echo ${uptime}) +uptime=$(uptime 2> /dev/null | tr -s " " | cut -d "," -f 1) +if [ -z "${uptime}" ] ; then + uptime="Unknown" +else + uptime=$(echo ${uptime}) +fi #shell="5.8" # Run zsh --version shell=$(zsh --version | cut -d " " -f 2) resolution=$(xrandr 2> /dev/null | grep "*" | head -1 | tr -s " " | cut -d " " -f 2) user_loaded=$(whoami) home_user="${HOME}" -cpu_model=$(lscpu | grep "Model name:" | tr -s " " | cut -d ":" -f 2) -cpu_model=$(echo ${cpu_model}) -mem_total=$(lsmem | grep "Total online memory:" | tr -s " " | cut -d ":" -f 2) -mem_total=$(echo ${mem_total}) +if [ -f /proc/cpuinfo ] ; then + cpu_model=$(cat /proc/cpuinfo | grep -i "model name" | head -1 | tr -s " " | cut -d ":" -f 2) + cpu_model=$(echo ${cpu_model}) +elif [ -f /usr/bin/lscpu ] ; then + cpu_model=$(lscpu 2>/dev/null | grep -i "Model name:" | tr -s " " | cut -d ":" -f 2) + cpu_model=$(echo ${cpu_model}) +else + cpu_model="Unknown" +fi +if [ -f /proc/meminfo ] ; then + mem_total_kb=$(cat /proc/meminfo | grep -i "memtotal" | tr -s " " | cut -d ":" -f 2) + mem_total_kb_num=$(echo ${mem_total_kb} | tr -s " " | cut -d " " -f 2) + mem_total_gb=$(expr ${mem_total_kb_num} / 1000 / 1000) + mem_total=$(echo ${mem_total_gb}G) +elif [ -f /usr/bin/lsmem ] ; then + mem_total=$(lsmem | grep -i "total online memory:" | tr -s " " | cut -d ":" -f 2) + mem_total=$(echo ${mem_total}) +else + mem_total="Unknown" +fi arch_system=$(uname -m) -hostname=$(hostname) +hostname=${HOST} session_type="${XDG_SESSION_TYPE}" clear