bin: script adjustments
This commit is contained in:
parent
31ef6a7109
commit
5c2f91ced2
|
@ -30,6 +30,31 @@ matches:
|
|||
params:
|
||||
cmd: pass info/email/aur
|
||||
# {{{1 ADDRESS
|
||||
- trigger: ";add"
|
||||
replace: "{{output}}"
|
||||
vars:
|
||||
- name: output
|
||||
type: shell
|
||||
params:
|
||||
cmd: pass info/address
|
||||
- triggers:
|
||||
- ";adb"
|
||||
- ";adt"
|
||||
replace: "{{output}}"
|
||||
vars:
|
||||
- name: output
|
||||
type: shell
|
||||
params:
|
||||
cmd: pass info/address-bt
|
||||
- triggers:
|
||||
- ";adw"
|
||||
- ";ads"
|
||||
replace: "{{output}}"
|
||||
vars:
|
||||
- name: output
|
||||
type: shell
|
||||
params:
|
||||
cmd: pass info/address-bt-short
|
||||
# Postal name
|
||||
- trigger: ";a0"
|
||||
replace: "{{output}}"
|
||||
|
@ -78,6 +103,7 @@ matches:
|
|||
type: shell
|
||||
params:
|
||||
cmd: "pass info/address | tail -1 | cut -d' ' -f2"
|
||||
# {{{1 NUMBERS
|
||||
- trigger: ";tel"
|
||||
replace: "{{output}}"
|
||||
vars:
|
||||
|
@ -85,21 +111,6 @@ matches:
|
|||
type: shell
|
||||
params:
|
||||
cmd: pass info/phone
|
||||
- trigger: ";adt"
|
||||
replace: "{{output}}"
|
||||
vars:
|
||||
- name: output
|
||||
type: shell
|
||||
params:
|
||||
cmd: pass info/address-bt
|
||||
- trigger: ";add"
|
||||
replace: "{{output}}"
|
||||
vars:
|
||||
- name: output
|
||||
type: shell
|
||||
params:
|
||||
cmd: pass info/address
|
||||
# {{{1 NUMBERS
|
||||
- trigger: ";tax"
|
||||
replace: "{{output}}"
|
||||
vars:
|
||||
|
@ -129,6 +140,7 @@ matches:
|
|||
params:
|
||||
cmd: pass info/banking/dkb | head -1
|
||||
# {{{1 EXTRAS
|
||||
# TODO turn into emacs template
|
||||
- trigger: ";sigo"
|
||||
replace: |-
|
||||
#+ATTR_ORG: :width 200
|
||||
|
|
|
@ -66,7 +66,9 @@ alias uloc='noglob sudo updatedb && loci'
|
|||
locei() { locate --all --basename "\\$1" "$@" | fselect }
|
||||
alias loce='noglob locei'
|
||||
# locate all
|
||||
alias loca='noglob sudo updatedb -l 0 --prunenames "" --prunefs "tmpfs sysfs debugfs" --prunepaths "" -o /var/cache/locate-all.db && loci --database /var/cache/locate-all.db'
|
||||
alias loca='noglob sudo updatedb -l 0 --prunenames "" --prunefs "tmpfs sysfs debugfs" --prunepaths "" -o /var/cache/locate-all.db &&
|
||||
sudo chmod +r /var/cache/locate-all.db &&
|
||||
loci --database /var/cache/locate-all.db'
|
||||
|
||||
# ZOXIDE {{{1
|
||||
alias c=z
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/bin/sh
|
||||
#!/bin/sh -e
|
||||
# Simple backup with borg
|
||||
if test $# -eq 0
|
||||
then borg list --format "{barchive:40} Created {time}{NL}"; exit $?
|
||||
then borg list --format "{barchive:40} Created {time}{NL}"
|
||||
exit $?
|
||||
fi
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
|
@ -15,7 +16,8 @@ while test $# -gt 0; do
|
|||
borg umount backups
|
||||
rm -d backups
|
||||
exit 0;;
|
||||
(ls) borg list --short "::$2" | tree --fromfile . | less -F; exit $?;;
|
||||
(tree) borg list --short "::$2" | tree --fromfile . | less -F
|
||||
exit $?;;
|
||||
(-n) run=arg-test; shift;;
|
||||
(*_) prefix=$1; shift;;
|
||||
(*) break;;
|
||||
|
|
|
@ -1,19 +1,28 @@
|
|||
#!/bin/sh -e
|
||||
#!/bin/bash -e
|
||||
# Test disk performance
|
||||
# Adapted from https://www.shellhacks.com/disk-speed-test-read-write-hdd-ssd-perfomance-linux/
|
||||
# Using bash because of redirects
|
||||
test "$1" = "-w" && write=true && shift
|
||||
disk="${1:-$(df --output=source . | tail -1)}"
|
||||
if test "$write"
|
||||
then exec &> >(tee "disktest-$(date +%F)")
|
||||
fi
|
||||
highlight() { echo "[4m$1[0m"; }
|
||||
|
||||
highlight "Checking SMART with hdparm"
|
||||
# Needs sudo for read test
|
||||
sudo hdparm -MWAgt "$disk"
|
||||
|
||||
if test $# -eq 0
|
||||
then echo "Write test:"
|
||||
then highlight "[1mWrite Test"
|
||||
sync
|
||||
# This prevents predictions by using random, but since that is too slow we have to copy a previously created file
|
||||
# sudo dd status=progress if=/dev/random of=/var/tmp/tempfile bs=1M count=1K && sudo dd status=progress if=/var/tmp/tempfile of=tempfile bs=1M count=1K
|
||||
highlight "Preparing:" &&
|
||||
sudo dd status=progress if=/dev/random of=/var/tmp/tempfile bs=1M count=1K &&
|
||||
highlight "Copying random bits:" &&
|
||||
sudo dd status=progress if=/var/tmp/tempfile of=tempfile bs=1M count=1K
|
||||
# TODO adjust size to disk
|
||||
sudo dd status=progress if=/dev/zero of=tempfile bs=1000K count=1000
|
||||
highlight "Copying zero bits:" &&
|
||||
sudo dd status=progress if=/dev/zero of=tempfile bs=1M count=1K
|
||||
sudo rm tempfile
|
||||
fi
|
||||
|
|
|
@ -26,12 +26,13 @@ case "$sel" in
|
|||
("") exit 1;;
|
||||
(/etc/sudoers) sudo visudo;;
|
||||
(/etc/fstab) sudoedit "$sel" && sudo findmnt --verify;;
|
||||
#systemctl daemon-reload && mount -af -o remount;;
|
||||
(/etc/default/grub) sudoedit "$sel" && sudo grub-mkconfig -o /boot/grub/grub.cfg;;
|
||||
(/etc/locale.gen) sudoedit "$sel" && sudo locale-gen;;
|
||||
(/etc/nginx/*) sudoedit "$sel" && sudo nginx -t && sudo nginx -s reload;;
|
||||
(/etc/caddy/*) sudoedit "$sel" && caddy validate --config /etc/caddy/Caddyfile && sudo systemctl reload-or-restart caddy;;
|
||||
(/etc/ssh/*) sudoedit "$sel" && sudo systemctl reload-or-restart sshd;;
|
||||
(/etc/network/interfaces*) sudoedit "$sel" && sudo service networking reload;;
|
||||
(*) $(test -w "$sel" || echo "sudo -E") edit "$sel";;
|
||||
(*) edit "$sel";;
|
||||
esac
|
||||
echo "$sel" | cat - "$conf_cache" | head -20 >"$conf_tmp" && mv "$conf_tmp" "$conf_cache"
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
# https://stackoverflow.com/questions/2507337/how-to-determine-a-terminals-background-color/30540928#30540928
|
||||
# Query a property from the terminal, e.g. background color.
|
||||
# XTerm Operating System Commands
|
||||
# "ESC ] Ps;Pt ST"
|
||||
|
||||
oldstty=$(stty -g)
|
||||
|
||||
# What to query?
|
||||
# 11: text background
|
||||
Ps=${1:-11}
|
||||
|
||||
stty raw -echo min 0 time 0
|
||||
# stty raw -echo min 0 time 1
|
||||
printf "\033]$Ps;?\033\\"
|
||||
# xterm needs the sleep (or "time 1", but that is 1/10th second).
|
||||
sleep 0.01
|
||||
read -r answer
|
||||
# echo $answer | cat -A
|
||||
result=${answer#*;}
|
||||
stty $oldstty
|
||||
# Remove escape at the end.
|
||||
echo $result | sed 's/[^rgb:0-9a-f/]\+$//'
|
Loading…
Reference in New Issue