diff --git a/.local/bin/scripts/browser b/.local/bin/scripts/browser new file mode 100755 index 0000000..2827ad6 --- /dev/null +++ b/.local/bin/scripts/browser @@ -0,0 +1,25 @@ +#!/bin/sh -e +# +# Usage: browser +# pipe html to a browser +# e.g. +# $ echo '

hi mom!

' | browser +# $ ron -5 man/rip.5.ron | browser + +if [ -t 0 ]; then + if [ -n "$1" ]; then + open $1 + else + cat <hi mom!' | browser +$ ron -5 man/rip.5.ron | browser +usage +fi +else + f="/tmp/browser.$RANDOM.html" + cat /dev/stdin > $f + xdg-open $f +fi diff --git a/.local/bin/scripts/delbig b/.local/bin/scripts/delbig index ec59b32..2d1772f 100755 --- a/.local/bin/scripts/delbig +++ b/.local/bin/scripts/delbig @@ -1,3 +1,4 @@ #!/bin/sh # Find and remove sizeable files -find -size +${1:-50}M -exec rm -vi {} + +case $1 in ([0-9]|[0-9][0-9]) threshold=$1; shift;; esac +find -size +${threshold:-50}M -exec rm -vi "$@" {} + diff --git a/.local/bin/scripts/dif b/.local/bin/scripts/dif index ee4784a..fc9da53 100755 --- a/.local/bin/scripts/dif +++ b/.local/bin/scripts/dif @@ -4,5 +4,5 @@ if file --brief --mime "$1" "$2" | grep --quiet audio then ff() { ffprobe -loglevel warning -print_format default=noprint_wrappers=1 -show_format -pretty "$@"; } $(test $(tput cols) -gt 120 && echo "diff --color=always --side-by-side" || echo "diff-color") --report-identical-files --label="$1" --label="$2" <(ff "$1") <(ff "$2") -else diff-color --report-identical-files "$@" +else wiked-diff "$@" # diff-color --report-identical-files "$@" fi | less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen diff --git a/.local/bin/scripts/git-aur b/.local/bin/scripts/git-aur index 69b05bf..3741ffc 100755 --- a/.local/bin/scripts/git-aur +++ b/.local/bin/scripts/git-aur @@ -24,12 +24,12 @@ case "$command" in git add -f .SRCINFO git commit -v "$@";; (push) - updpkgsums + grep -q SKIP PKGBUILD || updpkgsums git add -f *.install 2>/dev/null || true git aur commit -a "$@" git push;; (clean) - find "$aurdir" -mindepth 2 -maxdepth 2 \( -iname "*.pkg.tar.*" -o -type d -not -name ".*" \) \ + find "$aurdir" -mindepth 2 -maxdepth 2 \( -iname "*.pkg.tar.*" -o -iname "*.zip" -o -type d -not -name ".*" \) \ -print -exec sudo rm -rI {} +;; (*) echo "Unknown command!"; exit 3;; esac diff --git a/.local/bin/scripts/help b/.local/bin/scripts/help index c930fc3..f50f578 100755 --- a/.local/bin/scripts/help +++ b/.local/bin/scripts/help @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # open info-page, man-page or command help # depends: unbuffer # optdepends: highlight(dotfiles) @@ -17,25 +17,27 @@ showinfo() { cmd="$1" case "$cmd" in + (gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker|jrnl|difft|wiked-diff) unbuffer "$@" --help | $paginate;; + (caddy|stretchly|go|fossil) 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;; + (mpw) "$@" -h 2>&1 | $paginate;; + (plantuml) unbuffer "$@" -help | $paginate;; + (rails) { "$@" -H && "$@" --help; } | $paginate;; + (vlc) shift && unbuffer vlc --full-help "$@" | $paginate;; + (kdeconnect*) shift && kdeconnect-cli --help-all "$@" | $paginate;; + # Show manpage with tweaks + (pandoc) man pandoc; highlight "Extensions" && pandoc --list-extensions | paste -s -d' ';; + (swaymsg) test $# -gt 1 && shift && man sway "$@" || man swaymsg;; + (swaymsg-*) man sway "${1#swaymsg-}";; (zsh|zmv) # https://unix.stackexchange.com/questions/19290/zmv-for-zsh-dry-runs-and-man-pages for last; do true; done # need to install zsh-doc package for info pages showinfo zsh $(test "$last" != zsh && echo "$last") || LESS="$LESS +/^ *$last *\\[" man zshall;; - (gh|chordpro|bat|pdfjam|reflector|topgrade|r128gain|7z|kubectl|diffr|docker) unbuffer "$@" --help | $paginate;; - (caddy|stretchly|go|fossil) 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;; - (doom) "$@" --help;; - (mpw) "$@" -h 2>&1 | $paginate;; - (rails) { "$@" -H && "$@" --help; } | $paginate;; - (plantuml) unbuffer "$@" -help | $paginate;; - (vlc) shift && unbuffer vlc --full-help "$@" | $paginate;; - (kdeconnect*) shift && kdeconnect-cli --help-all "$@" | $paginate;; - (pandoc) man pandoc; highlight "Extensions" && pandoc --list-extensions | paste -s -d' ';; - (swaymsg) test $# -gt 1 && shift && man sway "$@" || man swaymsg;; - (swaymsg-*) man sway "${1#swaymsg-}";; (*) showinfo "$@" || man "$@" return=$? if test $return -gt 0 && which "$cmd" >/dev/null diff --git a/.local/bin/scripts/xdg-mime-file b/.local/bin/scripts/xdg-mime-file index 0803505..54e0672 100755 --- a/.local/bin/scripts/xdg-mime-file +++ b/.local/bin/scripts/xdg-mime-file @@ -1,8 +1,9 @@ #!/bin/sh -e # Use xdg-mime with a file's mime type +# ARGS: file [application] xdg-mime query default "$(xdg-mime query filetype "$1")" if test $# -gt 1; then - desktop="$(find /usr/share/applications -name "*$2*" | fzf -0 -1)" && + desktop="$(find /usr/share/applications $XDG_DATA_HOME/applications -name "*$2*" | fzf -0 -1)" && xdg-mime default "$desktop" "$(xdg-mime query filetype "$1")" && echo -n "Updated to: " && xdg-mime query default "$(xdg-mime query filetype "$1")"