bin: new scripts
This commit is contained in:
parent
dc9cee6da5
commit
863ef2051b
|
@ -1,5 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Write a CACHEDIR.TAG to mark this or the given directory as cache.
|
||||
echo 'Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by (application name).
|
||||
# For information about cache directory tags, see:
|
||||
# https://bford.info/cachedir/'>CACHEDIR.TAG
|
||||
# https://bford.info/cachedir/' > "${1:-.}/CACHEDIR.TAG"
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/bin/sh
|
||||
# Set exec flag on all files that should be executable
|
||||
find -maxdepth 4 \( -name "*.sh" -o -path '*/githooks/*' \) "$@" -exec chmod -v +x {} +
|
||||
case "$1" in ([0-9]) depth=$1; shift;; esac
|
||||
find -maxdepth ${depth:-4} \( -name "*.sh" -o -name "*.py" -o -path '*/githooks/*' \) "$@" -exec chmod -v +x {} +
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
typeset -A _clean_map
|
||||
_clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [v]=/var/cache)
|
||||
# TODO .mix - outdated version in socha
|
||||
_clean_home=(.ant .autopsy .bundle .cache .cargo .cpanm .docker .stack .hex .nix-defexpr .parallel .surf
|
||||
_clean_home=(.ant .autopsy .bundle .cargo .cpanm .docker .stack .hex .nix-defexpr .parallel .surf
|
||||
#.cache
|
||||
.yarn .node_modules .npm .pnpm-store .node-gyp .nv .electron .electron-gyp
|
||||
.gradle .gradle-kotlin-dsl .java .kscript .konan .m2 .openjfx
|
||||
.log luametatex-cache luatex-cache .texlive
|
||||
|
|
|
@ -15,8 +15,8 @@ if ! test "$command"; then
|
|||
(image/*) command="exiftool";;
|
||||
(*sqlite*) sqldiff --summary "${files[@]}" | grep -v '0 changes, 0 inserts, 0 deletes';; # TODO syntax highlighting for INSERT/UPDATE/DELETE
|
||||
(text/*)
|
||||
# Use wiked-diff only for text <10MB
|
||||
if test 10000000 -gt "$(stat --format=%s "${files[@]}" | paste -s -d'+' | bc)"
|
||||
# Use wiked-diff only for text <100KB
|
||||
if test 100000 -gt "$(stat --format=%s "${files[@]}" | paste -s -d'+' | bc)"
|
||||
then wiked-diff "${files[@]}"
|
||||
else diff --color=always --unified=1 --report-identical-files "${files[@]}"
|
||||
fi;;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Troubleshoot.sh
|
||||
# troubleshoot disk issues and log results
|
||||
# A more elaborate version of Troubleshoot.sh.
|
||||
|
||||
SUCCESS=0
|
||||
|
@ -32,4 +32,5 @@ do
|
|||
smartctl -i -A $e >> ${date}_Troubleshoot.log # Run smartctl on all disks
|
||||
fi
|
||||
done
|
||||
|
||||
exit $? # In this case, exit code = 99, since that is function return.
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Find config files with fzf, preview and edit them
|
||||
# Common config files are automatically checked/reloaded
|
||||
alias dedup='awk '"'"'!a[$0]++'"'"
|
||||
alias dedup-lines='awk '"'"'!a[$0]++'"'"
|
||||
|
||||
listconf() {
|
||||
{ cat "$conf_cache"
|
||||
|
@ -12,7 +12,7 @@ listconf() {
|
|||
\( -name Partitions -o -name mdn -o -name .git -o -name .local -o -name plugged \) -prune -o \
|
||||
! \( -iname "*.markdown" -o -iname "*.md" -o -name "Network Persistent State" -o -iname "*.pem" \) -a \
|
||||
-type f -readable -exec grep -lI '' {} + 2>/dev/null
|
||||
} | dedup
|
||||
} | dedup-lines
|
||||
}
|
||||
|
||||
conf_cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/$(basename "$0")"
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Rescursively find org-mode and other tags
|
||||
tag=$1
|
||||
shift
|
||||
grep --color=always --line-number --binary-files=without-match --directories=recurse --exclude-dir logseq --ignore-case ":$tag:
|
||||
@$tag\b" "$@"
|
|
@ -26,13 +26,15 @@ showinfo() {
|
|||
|
||||
cmd="$1"
|
||||
case "$cmd" in
|
||||
(fwupdmgr|hunt|rdoc|gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff|qpdf|ninja) unbuffer "$@" --help | sed 's|^[^ ].*:|[1m\0[22m|' | $paginate;;
|
||||
(fwupdmgr|hunt|rdoc|gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff|qpdf|ninja)
|
||||
unbuffer "$@" --help | sed 's|^[^ ].*:|[1m\0[22m|' | $paginate;;
|
||||
(caddy|stretchly|go|flutter)
|
||||
shift
|
||||
"$cmd" help "$@" | $paginate;;
|
||||
(doom|sgpt) "$@" --help;; # Paginates itself
|
||||
(mpw) "$@" -h 2>&1 | $paginate;;
|
||||
(rsgain) "$@" custom --help;;
|
||||
(spectre|plantuml|java) unbuffer "$@" -help | $paginate;;
|
||||
(mpw) "$@" -h 2>&1 | $paginate;;
|
||||
(rails) { "$@" -H && "$@" --help; } | $paginate;;
|
||||
(vlc) shift && unbuffer vlc --full-help "$@" | $paginate;;
|
||||
(kdeconnect*) shift && kdeconnect-cli --help-all "$@" | $paginate;;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh -e
|
||||
# Displays the latest files in the given directory or pwd
|
||||
# Lists the latest modified files in the given directory or pwd
|
||||
test "$1" = "-a" && all=true && shift
|
||||
for f in "${@:-$PWD}"
|
||||
do test $# -gt 1 && highlight "$f"
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#!/bin/sh -e
|
||||
# Add the modification date in front of the filename
|
||||
test $# -eq 0 && echo "predate [-s] [newname] <files...>" && exit 2
|
||||
IFS='\n'
|
||||
test "$1" = -s && short=true && shift
|
||||
# Whether to change the filename suffix after the date
|
||||
test ! -f "$1" && rename=true && name=$1 && shift || rename=false
|
||||
|
||||
for file
|
||||
do mv --verbose --interactive "$file" \
|
||||
"$(latest "$file" | head -2 | tail -1 |
|
||||
cut -c$(test "$short" && echo "3,4,6,7,9,10" || echo "-10"))$(
|
||||
cut -c$(test "$short" && echo "3,4,6,7,9,10" || echo "-10"))$(
|
||||
if $rename
|
||||
then echo "$(test "$name" && echo "_$name").${file##*.}"
|
||||
else echo "_$file" | sed 's/^_2\?\([0-9]\{2,3\}\)-\([0-9]\{2\}\)\(-[0-9]\{2\}\)\?_\?/_/'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
# Execute a gradle task (default test) until it fails
|
||||
# Execute a gradle task (by default "test") until it fails
|
||||
code=0
|
||||
case "$1" in ([0-9]*) code=$1; shift;; esac
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Recursively add replaygain to the given files or from the current directory
|
||||
r128gain $(test -f "$1" || echo '--recursive') --skip-tagged --preserve-times 1 "${@:-.}"
|
||||
# rsgain custom --album --skip-existing --tagmode=i
|
||||
# Need a find command, call for each album
|
||||
# rsgain easy --skip-existing --multithread=${SPARE_CORES:-3} "${@:-.}"
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
# Rename files according to a given extended regex sed expression
|
||||
sedexpr="$1"
|
||||
shift
|
||||
find "$@" -exec sh -c 'mv -iv "{}" "$(echo "{}" | sed -E "'$sedexpr'")" 2>/dev/null' \;
|
||||
find "$@" -exec sh -c 'mv -iv "{}" "$(echo "{}" | sed -E "'"$sedexpr"'")" 2>/dev/null' \;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
mkdir -p $(dirname $1)
|
||||
touch "$@"
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh -ex
|
||||
# Generate a cloud-init hashed password for the given machine and copy it
|
||||
passwd=$(mkpasswd --method=SHA-512 --rounds=4096 $(pass mpw -t basic "$@"))
|
||||
echo $passwd
|
||||
echo $passwd | wl-copy
|
|
@ -2,6 +2,9 @@
|
|||
# xdg-open all given files
|
||||
# TODO handle .desktop-files with gtk-launch/dex/kioclient exec, add selector from xdg-mime-file
|
||||
while test $# -gt 0; do
|
||||
xdg-open "$(case "$1" in (-*) echo './';; esac)$1"
|
||||
case $1 in
|
||||
(*.epub) okular "$1" &;;
|
||||
(*) xdg-open "$(case "$1" in (-*) echo './';; esac)$1";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue