bin: update lots of shortcuts and add a few
This commit is contained in:
parent
e46ecf6f3f
commit
4063085286
|
@ -9,6 +9,9 @@ alias sce="$sudo systemctl enable --now"
|
|||
alias sced="$sudo --preserve-env=EDITOR systemctl edit"
|
||||
alias scr="$sudo systemctl daemon-reload && $sudo systemctl reload-or-restart"
|
||||
|
||||
alias hist='history | less'
|
||||
alias m='mv -vi'
|
||||
|
||||
highlight() { echo "[4m$1[0m"; }
|
||||
status() {
|
||||
highlight 'System'
|
||||
|
|
|
@ -44,7 +44,7 @@ yas() {
|
|||
)
|
||||
if test -n "$pkg"
|
||||
then echo "Installing $pkg..."
|
||||
cmd="yay -Sy --batchinstall --rebuild $pkg"
|
||||
cmd="yay -Sy --batchinstall --rebuildtree $pkg"
|
||||
print -s "$cmd"
|
||||
eval "$cmd"
|
||||
rehash
|
||||
|
|
|
@ -66,6 +66,7 @@ sudos() {
|
|||
sudo "$(which $cmd)" "$@"
|
||||
}
|
||||
|
||||
# Outputs the resolved alias if it is a simple one-word alias
|
||||
resolvealias() {
|
||||
alias "$1" 2>/dev/null | sed -n "s|$1='\?\(noglob \)\?\([-A-z]\+\)'\?\$|\2|p" | grep -m 1 . || echo $1
|
||||
}
|
||||
|
@ -148,7 +149,7 @@ edit-shell() {
|
|||
# Edit an executable in the PATH
|
||||
edit-bin() {
|
||||
local toedit="$(resolvealias "$1")"
|
||||
case "$toedit" in (*\ text*);; (*) toedit="$1";; esac
|
||||
#case "$toedit" in (*\ text*);; (*) toedit="$1";; esac
|
||||
if f="$(which "$toedit" 2>/dev/null)" && test -f "$f"
|
||||
then edit "$f"
|
||||
else edit-shell -f "$toedit"
|
||||
|
@ -474,7 +475,7 @@ alias updateUtils="updateDeps build.gradle.kts '"'"com.github.Xerus2000.util", "
|
|||
updateKarma() { rpl "karma-runner.github.io/[^/]\+/" "karma-runner.github.io/$1/"; }
|
||||
|
||||
# Kill all shell background processes
|
||||
alias killbg='kill ${${(v)jobstates##*:*:}%=*}'
|
||||
alias killbg='kill -9 ${${(v)jobstates##*:*:}%=*}'
|
||||
|
||||
# Kill all processes that match
|
||||
killm() {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# video thumbnails via mtn, pdf pages from pdftoppm
|
||||
# - text files are displayed through bat
|
||||
# Automatically requests elevation through sudo when needed
|
||||
# TODO .raw,.iso,.qcow2
|
||||
|
||||
set -o pipefail
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Suspend screen until enter is pressed
|
||||
test "$1" && sleep $1
|
||||
xset dpms force off
|
||||
swaymsg "output * dpms off"
|
||||
read
|
||||
|
|
|
@ -17,7 +17,7 @@ while test $# -gt 0; do
|
|||
borg umount backups
|
||||
rm -d backups
|
||||
exit 0;;
|
||||
(tree) borg list --short "::$2" | tree --fromfile . | less -F
|
||||
(tree) borg list --short $(case $2 in (*::*) echo "$2";; (*) echo "::$2";; esac) | tree --fromfile . | less -F
|
||||
exit $?;;
|
||||
(-n) run=arg-test; shift;;
|
||||
(*_) prefix=$1; shift;;
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/sh -ex
|
||||
#!/bin/sh
|
||||
# Set exec flag on all files that should be executable
|
||||
find -maxdepth 4 -name "*.sh" -o -path '*/githooks/*' "$@" -exec chmod -v +x {} +
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# env: MUSIC
|
||||
# args: either a playlist file name, or a list of terms which all have to match
|
||||
# TODO fails on "Alchemy"
|
||||
# TODO implement tags
|
||||
PLAYLISTS="${PLAYLISTS:-$MUSIC/Playlists}"
|
||||
mpc -q clear
|
||||
if test -z "$1"
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh -e
|
||||
# Revives a file that has been deleted from the last known commit.
|
||||
# Filename can be given with any amount of complete prefix directories.
|
||||
file="$1"
|
||||
commit=$(git log --format="%H" -1 -- "*/$file")
|
||||
test -z "$commit" && echo "$file not found in history" >&2 && exit 2
|
||||
git restore --worktree --source="$commit~" -- $(git diff-tree --no-commit-id --name-only -r $commit | grep "/$file$")
|
|
@ -26,15 +26,15 @@ showinfo() {
|
|||
cmd="$1"
|
||||
case "$cmd" in
|
||||
# TODO extract help in standard format from scripts
|
||||
(hunt|rdoc|gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff|qpdf) unbuffer "$@" --help | $paginate;;
|
||||
(fwupdmgr|hunt|rdoc|gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff|qpdf) unbuffer "$@" --help | sed 's|^[^ ].*:|[1m\0[22m|' | $paginate;;
|
||||
(caddy|stretchly|go|fossil|flutter) test "$cmd" = "fossil" -a $# -eq 1 && repo="$(locate -b -l 1 "fossil*.fossil")" && fossil ui "$repo" && exit
|
||||
# TODO view fossil ui in terminal
|
||||
shift
|
||||
"$cmd" help "$@" | $paginate;;
|
||||
# Non-standard help flags
|
||||
(doom) "$@" --help;;
|
||||
(doom) "$@" --help;; # Doom paginates itself
|
||||
(mpw) "$@" -h 2>&1 | $paginate;;
|
||||
(plantuml|java) unbuffer "$@" -help | $paginate;;
|
||||
(spectre|plantuml|java) unbuffer "$@" -help | $paginate;;
|
||||
(rails) { "$@" -H && "$@" --help; } | $paginate;;
|
||||
(vlc) shift && unbuffer vlc --full-help "$@" | $paginate;;
|
||||
(kdeconnect*) shift && kdeconnect-cli --help-all "$@" | $paginate;;
|
||||
|
|
|
@ -3,11 +3,17 @@ test "$1" = "-q" && quiet=$1 && shift
|
|||
case "$1" in ([0-9]) page=$1; shift;; esac
|
||||
test ! -r "$1" && echo "Usage: sign [page] <document.pdf> [hoffset (-160) [voffset (-310) [scale [signature-image]]]]" && exit 1
|
||||
|
||||
signature=$(pass info/signature$(test -n "$5" && echo "-$5") || echo "$5")
|
||||
|
||||
# TODO make filenames unique and don't rerun unneccessarily
|
||||
tmp_base=/tmp/sign
|
||||
mkdir -p $tmp_base
|
||||
|
||||
texttopdf() {
|
||||
out="$tmp_base/stamp.pdf"
|
||||
echo "$1" | enscript -B -f Arial12 -o- | ps2pdf - >"$out"
|
||||
echo "$out"
|
||||
}
|
||||
signature=$(test -f "$5" && echo "$5" || pass info/signature$(test -n "$5" && echo "-$5") || texttopdf "$5")
|
||||
|
||||
# TODO make filenames unique and don't rerun unneccessarily
|
||||
tmp_signed=$tmp_base/$1_last-signature.pdf
|
||||
tmp_reversed=$tmp_base/$1_reverse.pdf
|
||||
sig=$tmp_base/signature_offset.pdf
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences/33206814#33206814
|
||||
|
||||
print("\\033[XXm")
|
||||
print("-- Use Ctrl-V ESC if not using printf")
|
||||
|
||||
for i in range(30,37+1):
|
||||
print("\033[%dm%d\t\t\033[%dm%d" % (i,i,i+30,i+30));
|
||||
|
@ -22,16 +23,13 @@ print(" ")
|
|||
def illustrate(command, *text):
|
||||
print("\033[", command, "m\\033[", command, "m - ", *text, sep="", end="\t")
|
||||
|
||||
def toggle(command, text):
|
||||
def toggle(command, text, add = 20):
|
||||
illustrate(command, text, " on")
|
||||
illustrate(command + 20, text, " off\033[0m")
|
||||
illustrate(command + add, text, " off\033[0m")
|
||||
print()
|
||||
toggle(1, "Bold")
|
||||
toggle(1, "Bold", 21)
|
||||
toggle(2, "Grey")
|
||||
toggle(3, "Italic")
|
||||
toggle(4, "Underline")
|
||||
#toggle(5, "Bold")
|
||||
#toggle(6, "Bold")
|
||||
toggle(7, "Highlight")
|
||||
#toggle(8, "Bold")
|
||||
toggle(9, "Strike")
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
# If first arg is a digit, it displaces the default depth of 3
|
||||
# Any other arguments (usually pathnames) are passed on to the tree command
|
||||
case "$1" in ([0-9]) depth=$1; shift;; esac
|
||||
tree -a --dirsfirst --du -h -C -L ${depth:-3} "$@" | ${PAGER:-less} -rF
|
||||
tree --dirsfirst --du -h -C -L ${depth:-3} -I node_modules "$@" | ${PAGER:-less} -rF
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
# Unlock failed logins for user
|
||||
faillock --user ${USER:-$1} --reset
|
Loading…
Reference in New Issue