From 8f429a45eacf1203fbff77a068237d23574e06d2 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Wed, 27 Oct 2021 10:00:54 +0200 Subject: [PATCH] bin: expand moul --- .local/bin/scripts/b | 2 +- .local/bin/scripts/clean | 1 + .local/bin/scripts/moul | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.local/bin/scripts/b b/.local/bin/scripts/b index f651e44..8e71958 100755 --- a/.local/bin/scripts/b +++ b/.local/bin/scripts/b @@ -16,7 +16,7 @@ tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$' case "$($elevate file --dereference --mime "$last")" in *inode/directory*) tput sgr0 && $(test -x "$last" || echo "sudo") ls -l --color=always --human-readable --group-directories-first --file-type --dereference-command-line --all "$@" | less -XF;; - *binary) expr "$(file "$last")" : ".*compressed" >/dev/null && /usr/share/nvim/runtime/macros/less.sh "$@";; + *binary) expr "$(file "$last")" : ".*: .*compress" >/dev/null && /usr/share/nvim/runtime/macros/less.sh "$@";; *) $elevate bat --style header "$@" "$(test -n "$elevate" || echo "--pager=less -XF")" tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last" ;; diff --git a/.local/bin/scripts/clean b/.local/bin/scripts/clean index 71a4261..6987504 100755 --- a/.local/bin/scripts/clean +++ b/.local/bin/scripts/clean @@ -33,6 +33,7 @@ fi highlight "d to recursively remove development caches" if [[ $1 =~ "d" ]]; then + rm -rf .npm .yarn find -name "src" -prune -o \ -type d \( -name ".gradle" -o -name "generated" -o -name "dist-newstyle" -o -name "cache" -o -name "node_modules" -o -name "cmake_build" \) \ -print -exec rm -r {} + -prune diff --git a/.local/bin/scripts/moul b/.local/bin/scripts/moul index b0dc475..93cf5d8 100755 --- a/.local/bin/scripts/moul +++ b/.local/bin/scripts/moul @@ -1,3 +1,8 @@ -#!/bin/sh -# Mount a partition by label automatically -sudo mount -o rw,X-mount.mkdir -L "$1" "${2:-/mnt/$1}" +#!/bin/sh -e +# Mount a partition by label or device identifier automatically +#test "$1" = "-u" && umount "$mountpoint"; exit $? +mountpoint="${2:-${XDG_RUNTIME_DIR:-/mnt}/$1}" +case "$1" in (sd*|loop*) partition="/dev/$1";; (*) partition="-L $1";; esac +mountpoint "$mountpoint" >/dev/null || sudo mount -v -o users,X-mount.mkdir $partition "$mountpoint" "${@:3}" +cd $mountpoint +exec $SHELL