config/shell: improve automation scripts
This commit is contained in:
parent
99053ecd32
commit
9f0aae589a
|
@ -1,10 +1,35 @@
|
|||
test -n "$PS1" || return 0
|
||||
|
||||
alias sc="sudo systemctl"
|
||||
alias scs="sudo systemctl status"
|
||||
alias sce="sudo systemctl enable --now"
|
||||
alias scr="sudo systemctl reload-or-restart"
|
||||
alias status="sudo systemctl list-units --failed || service --status-all; tmux ls; sudo docker ps || sudo systemctl status docker"
|
||||
test $(id -u) -eq 0 || sudo=sudo
|
||||
|
||||
alias sc="$sudo systemctl"
|
||||
alias scs="$sudo systemctl status"
|
||||
alias sce="$sudo systemctl enable --now"
|
||||
alias sced="$sudo --preserve-env=EDITOR systemctl edit"
|
||||
alias scr="$sudo systemctl reload-or-restart"
|
||||
|
||||
highlight() { echo "[4m$1[0m"; }
|
||||
status() {
|
||||
highlight 'System'
|
||||
free -h
|
||||
df -h -T --exclude-type=tmpfs --exclude-type=devtmpfs --exclude-type=squashfs --exclude-type=overlay
|
||||
zfs list -d 0
|
||||
highlight 'Internet'
|
||||
#--color=always
|
||||
ip -brief address | grep --color=none -E '^(wl|en|tun|vmbr)'
|
||||
ip route
|
||||
echo -n 'IPv4: ' && timeout 3s ping example.com -A -c 3 -w 3 -q -4
|
||||
echo -n 'IPv6: ' && timeout 3s ping example.com -A -c 3 -w 3 -q -6
|
||||
highlight 'Programs'
|
||||
tmux ls
|
||||
$sudo systemctl --no-pager list-units --failed || service --status-all
|
||||
if type docker >/dev/null
|
||||
then $sudo docker ps || $sudo systemctl status docker
|
||||
fi
|
||||
}
|
||||
|
||||
alias u='$sudo apt update && sudo apt upgrade'
|
||||
alias ur='u && $sudo reboot'
|
||||
|
||||
# Diff recursively
|
||||
difr() { diff --color=always --unified=1 --recursive "$@" | less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen; }
|
||||
|
|
|
@ -12,7 +12,7 @@ indent_character: '|'
|
|||
journals:
|
||||
default: ~/data/2-box/journal/jrnl.txt
|
||||
intentions: ~/data/2-box/journal/intentions.txt
|
||||
nug: ~/data/2-box/journal/nugnug.txt
|
||||
nug: ~/data/2-box/journal/nug.txt
|
||||
linewrap: 99
|
||||
tagsymbols: '@'
|
||||
template: false
|
||||
|
|
|
@ -316,10 +316,15 @@ sshl() {
|
|||
local authcache="/var/tmp/ssh-keys"
|
||||
mkdir -p "$authcache"
|
||||
local file="$authcache/$1"
|
||||
ssh -G "$1" | grep --silent "^user root$" &&
|
||||
! [[ "$1" =~ "pve.*" ]] &&
|
||||
! [[ "$1" =~ "encee.*" ]] &&
|
||||
! [[ "$1" =~ ".*fmh.de" ]] &&
|
||||
pass=pass
|
||||
test "$all" &&
|
||||
pass scp ~/.bash_aliases "$1:" &&
|
||||
pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc'
|
||||
if ssh -G "$1" | grep --silent "^user root$" && ! [[ "$1" =~ "pve*" ]]
|
||||
$pass scp ~/.bash_aliases "$1:" &&
|
||||
$pass ssh "$1" 'grep -q ".bash_aliases" .bashrc || echo "source ~/.bash_aliases" >>.bashrc'
|
||||
if test -n "$pass"
|
||||
then pass ssh "$@"
|
||||
else
|
||||
test ! -e "$file" &&
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
# Automatically set screen brightness based on time of day.
|
||||
# OLD: value=$(expr 100 - $(expr 13 - $(date +%H) | tr -d -) \* 5)
|
||||
# S Function: echo "(c($(date +%H) / 4 - 3) + 1) * 50" | bc -l
|
||||
value=$(echo "l=(100 - 1.5 * ( 11 - $(date +%H) ) ^ 2); if(l > 0) l else 3" | bc -l)
|
||||
light -S $value
|
||||
{ date && echo $value; } >>/var/log/autolight
|
Loading…
Reference in New Issue