bin: improve helpers, add own and dsync
This commit is contained in:
parent
2ed5ad49fb
commit
5070c97ffe
|
@ -41,7 +41,8 @@ wh() {
|
|||
res=$(which "$@")
|
||||
if expr "$res" : "${@:$#}: aliased to" >/dev/null && ! expr "$res" : ".*builtin" >/dev/null
|
||||
then echo "$res" | bat --style=plain --language=sh &&
|
||||
wh $(expr "$res" : "${@:$#}: aliased to ${@:$#} " >/dev/null && echo "-p") $(echo "$res" | cut -d' ' -f$(expr 5 '&' "$res" : ".*to \(sudo\|noglob\) " '|' 4) | cut -d'(' -f2)
|
||||
tool="$(echo "$res" | cut -d' ' -f$(expr 5 '&' "$res" : ".*to \(sudo\|noglob\) " '|' 4) | cut -d'(' -f2)"
|
||||
wh $(test $tool = $1 && echo "-p") $tool
|
||||
# use command which for other shells
|
||||
else test -r "$res" && b --style=header "$res" || echo "$res" | bat --style=plain --language=sh
|
||||
fi
|
||||
|
@ -77,7 +78,7 @@ edshell() {
|
|||
esac
|
||||
test -f "$file" || return 2
|
||||
checksum="$(md5sum "$file")"
|
||||
$EDITOR "$(test "$line" && echo "+normal! ${line}ggzx")" "${file%:*}"
|
||||
$EDITOR "$(test "$line" && echo "+normal! ${line}ggzx" || echo "--")" "${file%:*}"
|
||||
test "$checksum" != "$(md5sum $file)" && source "$HOME/.zprofile" && exec $SHELL
|
||||
}
|
||||
|
||||
|
|
|
@ -13,14 +13,18 @@ last=${last:-.}
|
|||
test -x "$(dirname "$last")" &&
|
||||
{ test -r "$last" || ! test -e "$last"; } ||
|
||||
elevate=sudo
|
||||
tput setaf 4 && $elevate file -E "$last" | ( grep -v --color=never 'directory$' || true )
|
||||
tput setaf 4 && $elevate file -E "$last" | { grep -v --color=never 'directory$' || true; }
|
||||
|
||||
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) if expr "$(file "$last")" : ".*: .*compress" >/dev/null
|
||||
(*binary)
|
||||
if expr "$(file "$last")" : ".*: .*compress" >/dev/null
|
||||
then /usr/share/nvim/runtime/macros/less.sh "$@"
|
||||
fi;;
|
||||
(*) $elevate bat --style header "$@" --pager 'less -RXF'
|
||||
fi
|
||||
tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
|
||||
;;
|
||||
(*) $elevate bat --style header "$@" --pager 'less -RXF'
|
||||
tput setaf 3 && $elevate stat --format '%A size %sB, birth: %.10w mod %.10y' "$last"
|
||||
# TODO don't duplicate stat
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -2,13 +2,16 @@
|
|||
# Cleans up files according to given parameters
|
||||
|
||||
typeset -A _clean_map
|
||||
_clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp)
|
||||
_clean_map=([h]=$XDG_CACHE_HOME [t]=/var/tmp [l]=/var/log [c]=/var/cache)
|
||||
# Directories to always clean
|
||||
_clean_folders=()
|
||||
_clean_folders=(~/.ant ~/.autopsy ~/.cargo ~/.electron-gyp ~/.nix-defexpr ~/.npm ~/.parallel ~/.stack ~/.yarn
|
||||
~/.lesshst)
|
||||
|
||||
for f in $_clean_folders
|
||||
do test -d $f && rm -rv $f
|
||||
|
||||
for f in ${_clean_folders[@]}
|
||||
do test -f $f || test -d $f && highlight $f && rm -rf $f
|
||||
done
|
||||
find $HOME -maxdepth 2 -not -name ".stfolder" -type d -empty -exec rm -vd {} +
|
||||
|
||||
highlight "g to clean gradle"
|
||||
if [[ $1 =~ "g" ]]; then
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
# rsync directory properly
|
||||
# suffix both dirs with / to act on contents
|
||||
rsync -recursive --specials --times --links --delete --info=progress2,remove,symsafe,flist,del --human-readable "$@"
|
|
@ -19,7 +19,7 @@ then shift
|
|||
then pushd "$(dirname "$path")" >/dev/null && cat "$path" | sed '/#.*/D' | xargs --delim='\n' "$0" -r $verbose && popd >/dev/null
|
||||
else
|
||||
test -n "$verbose" && echo "Finding path '$path' $(test "$arg" != "$path" && echo "from '$arg' ")(MUSIC: '$MUSIC', PWD: '$PWD')" >&2
|
||||
find "$path" -name "*.flac" -o -name "*.mp3" | sort | while read file
|
||||
find "$path" -iname "*.flac" -o -iname "*.mp3" -o -iname "*.ogg" -o -iname "*.opus" | sort | while read file
|
||||
do case "$path" in
|
||||
($MUSIC/*) echo "${file#$MUSIC/}";;
|
||||
(*) mkdir -p "$LINKS" && ln -fs "$file" "$LINKS/$(basename "$file")" && echo "${LINKS#$MUSIC/}/$(basename "$file")";;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
# Take ownership of the given files recursively
|
||||
sudo chown -R --preserve-root $USER "$@"
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh -e
|
||||
# Move roam files into subfolders
|
||||
cd $DATA/2-standards/notes/roam
|
||||
cd $DATA/2-standards/notes
|
||||
find . -mindepth 1 -type d -printf '%f\n' | while read dir; do grep -l --directories=skip "#+filetags: :$dir" * | xargs --verbose --no-run-if-empty mv -t "$dir"; done
|
||||
|
|
Loading…
Reference in New Issue