commit 4e3463691cf9d0262cc4d7d68d1cfb5423e7405a Author: michael Date: Sun Mar 27 01:39:25 2022 +0100 initial diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2c57784 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,15 @@ +[submodule "grc"] + path = grc + url = https://github.com/garabik/grc +[submodule "k"] + path = k + url = https://github.com/supercrabtree/k +[submodule "pure"] + path = pure + url = https://github.com/sindresorhus/pure +[submodule "zsh-autosuggestions"] + path = zsh-autosuggestions + url = https://github.com/zsh-users/zsh-autosuggestions +[submodule "zsh-syntax-highlighting"] + path = zsh-syntax-highlighting + url = https://github.com/zsh-users/zsh-syntax-highlighting diff --git a/grc b/grc new file mode 160000 index 0000000..f4a579e --- /dev/null +++ b/grc @@ -0,0 +1 @@ +Subproject commit f4a579e08d356a3ea00a8c6fda7de84fff5f676a diff --git a/grc.zsh b/grc.zsh new file mode 100644 index 0000000..01d34f1 --- /dev/null +++ b/grc.zsh @@ -0,0 +1,95 @@ +#!/usr/bin/env zsh + +if [ "$TERM" = dumb ] || (( ! $+commands[grc] )) +then + return +fi + +# Supported commands +cmds=( + as + ant + blkid + cc + configure + curl + cvs + df + diff + dig + dnf + docker + docker-compose + docker-machine + du + env + fdisk + findmnt + free + g++ + gas + gcc + getfacl + getsebool + gmake + id + ifconfig + iostat + ip + iptables + iwconfig + journalctl + kubectl + last + ldap + lolcat + ld + ls + lsattr + lsblk + lsmod + lsof + lspci + make + mount + mtr + mvn + netstat + nmap + ntpdate + php + ping + ping6 + proftpd + ps + sar + semanage + sensors + showmount + sockstat + ss + stat + sysctl + systemctl + tcpdump + traceroute + traceroute6 + tune2fs + ulimit + uptime + vmstat + wdiff + whois +) + +# Set alias for available commands. +for cmd in $cmds ; do + if (( $+commands[$cmd] )) ; then + $cmd() { + grc --colour=auto ${commands[$0]} "$@" + } + fi +done + +# Clean up variables +unset cmds cmd diff --git a/k b/k new file mode 160000 index 0000000..e2bfbaf --- /dev/null +++ b/k @@ -0,0 +1 @@ +Subproject commit e2bfbaf3b8ca92d6ffc4280211805ce4b8a8c19e diff --git a/pure b/pure new file mode 160000 index 0000000..5b458ba --- /dev/null +++ b/pure @@ -0,0 +1 @@ +Subproject commit 5b458ba5b75f49a8071d53c343f1a23631f7bced diff --git a/stats.sh b/stats.sh new file mode 100755 index 0000000..6832283 --- /dev/null +++ b/stats.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env zsh + +l="$(tput setaf 245)" # left +h="$(tput setaf 10)" # highlight +n="$(tput setaf 28)" # normal + +ip=$(hostname -I 2>/dev/null | awk '{print $1}') +[ -z $ip ] && ip="$(curl -4s ifconfig.me)" +#sessions=$(who | awk '{print $5}' | wc -l)" session" +sessions=$(echo $(who | awk '{print $5}' | wc -l))" session" +[ $sessions != "1 session" ] && sessions+=s +uptime=$(($(cat /proc/uptime | cut -d'.' -f1)/86400))" day" +[ $uptime != "1 day" ] && uptime+=s +load=$(awk '{print $1, $2, $3}' /proc/loadavg) +#ram_free=$(free -m | grep "m:" | awk '{print $7}') +ram_free=$(free -m | grep "m:" | awk '{print $4}') +swp_used=$(free -m | grep "p:" | awk '{print $3}') +space1=$(df -h / | grep dev | awk '{print $4}') +#space2=$(df -h /srv | grep dev | awk '{print $4}') + +echo +echo " ${l}Host: ${h}$(hostname) @ $ip ${n}(${h}$sessions ${n}open)" +echo " ${l}Load: ${h}$load${n}, ${h}$uptime ${n}up" +echo " ${l}Memory: ${h}${ram_free}M ${n}free, ${h}${swp_used}M ${n}swapped" +echo " ${l}Space: ${h}/ ${h}$space1 ${n}free" +#echo " ${l}Space: ${h}/ ${h}$space1 ${n}free, ${h}/srv $space2 ${n}free" + + +if command -v vnstat &> /dev/null; then +traffic_day=$(vnstat --oneline | awk -F';' '{print $6}') +traffic_month=$(vnstat --oneline | awk -F';' '{print $11}') +echo " ${l}Traffic: ${h}$traffic_day ${n}today, ${h}$traffic_month ${n}this month" +fi + +#echo + +#warn=" $(tput blink; tput setaf 196)!$(tput sgr0)" +#fortune -os | cowsay -f `find /usr/share/cowsay/cows -type f -size -400c | shuf -n 1` | lolcat -f -S 50 -p 10 | sed 's/^/ /' +#fortune -asn 300 | cowsay -nf small | lolcat -f -S 50 -p 10 | sed 's/^/ /' + +echo "$(tput setaf 245)" +#fortune -asn 300 | cowsay -nf small | sed 's/^/ /' +fortune -as | cowsay -nf small | sed 's/^/ /' +echo "$(tput sgr0)" diff --git a/zsh-autosuggestions b/zsh-autosuggestions new file mode 160000 index 0000000..a411ef3 --- /dev/null +++ b/zsh-autosuggestions @@ -0,0 +1 @@ +Subproject commit a411ef3e0992d4839f0732ebeb9823024afaaaa8 diff --git a/zsh-syntax-highlighting b/zsh-syntax-highlighting new file mode 160000 index 0000000..c5ce001 --- /dev/null +++ b/zsh-syntax-highlighting @@ -0,0 +1 @@ +Subproject commit c5ce0014677a0f69a10b676b6038ad127f40c6b1 diff --git a/zshrc b/zshrc new file mode 100644 index 0000000..20bb4d2 --- /dev/null +++ b/zshrc @@ -0,0 +1,90 @@ +export ZSHDIR=$HOME/.config/zsh +export PATH=$HOME/bin:$PATH +export FPATH=$FPATH:$ZSHDIR/pure +export HISTFILE=$HOME/.zsh_history +export OS="$(uname -s)" +#export TERM=xterm-256color +export EDITOR=nano +export HISTSIZE=1000000 +export SAVEHIST=1000000 +export HISTORY_IGNORE="(l *|la *|ls *|cd|cd *|rm *|echo *|find *|cat *|ccat *|apt*|mkdir *|rmdir *|rsync *|git *|nano *|screen *|traceroute *|ping *|whois *|md5sum *|timeout *|tmux *|mount *|openssl *|watch *|dpkg *|chown *|mv *|cp *|grc *|scp *|tail *|wget *|zcat *|time *|curl *|while *|unp *|attr *|dialog *|sysbench *|ftp *|truncate *|ln *|grep *|chmod *|*grep*|man *|pidof *|nslookup *|umount *|sleep *|pushd *| popd *|kill *|su *|tar *|touch *|7z *|hexdump *|du|du *|ack *|\\\\*)" +setopt hist_reduce_blanks hist_ignore_space hist_ignore_all_dups interactive_comments share_history + +alias ..="cd .." +alias ff="find . -type f -iname" +alias fd="find . -type d -iname" +alias nolog="unset HISTFILE" +alias grep="grep --color=auto" +alias cdu="cdu.pl -sridh" +alias l="k -h --no-vcs --group-directories-first" +alias la="k -h -A --no-vcs --group-directories-first" +alias bell='echo -en "\007"' +if [ "$OS" = "Linux" ]; then +alias rm="rm -I" +alias update="sudo apt-get update && sudo apt-get upgrade; sudo apt-get clean" +elif [ "$OS" = "Darwin" ]; then +alias update="brew update && brew upgrade" +fi + +function cheat { curl cheat.sh/$1 } +function mcd { mkdir -p $1; cd $1 } +function pw { echo `tr -dc ACDEFHJKLMNPRTUVWX