bin: update elevation mechanisms
This commit is contained in:
parent
f6bed70b5f
commit
7c6706074b
|
@ -189,9 +189,10 @@ alias startMinecraftServer='curl https://ipinfo.io/ip | xclip -sel clip && cd ~/
|
|||
alias u='topgrade'
|
||||
|
||||
alias j='jrnl'
|
||||
jn() { jrnl -to today "$@" | bat --style=plain --pager="less +G" }
|
||||
jn() { jrnl -to today "$@" | less +G }
|
||||
compdef jn=jrnl
|
||||
alias jnc='jn -contains'
|
||||
alias jne='jrnl --edit'
|
||||
|
||||
npm-reinstall() {
|
||||
rm -rf $TMPDIR/react-*
|
||||
|
|
|
@ -8,7 +8,7 @@ for last; do true; done
|
|||
last=${last:-.}
|
||||
|
||||
# Elevate permissions if the file exists but is not accessible
|
||||
test -x "$(dirname $last)" || elevate=sudo
|
||||
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 )
|
||||
|
||||
case "$($elevate file --dereference --mime "$last")" in
|
||||
|
|
|
@ -17,7 +17,7 @@ conf_tmp="${conf_cache}.tmp"
|
|||
mkdir -p "$conf_cache_dir"
|
||||
touch "$conf_cache"
|
||||
|
||||
sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r "{}" || echo "sudo") bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches")
|
||||
sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r {} || echo "sudo") bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches")
|
||||
case "$sel" in
|
||||
"") exit 1;;
|
||||
/etc/sudoers) sudo visudo;;
|
||||
|
|
|
@ -11,7 +11,7 @@ case $1 in
|
|||
(vlc) unbuffer vlc --full-help "${@:2}" | $paginate;;
|
||||
(gh|chordpro) $@ --help | $paginate;;
|
||||
(caddy) $1 help ${@:2} | $paginate;;
|
||||
(*) man "$@" || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } || ( "$@" --help || "$@" -help ) 2>&1 | $paginate;;
|
||||
(*) man "$@" || { info "$1" -w | grep -v "manpages" && pinfo "$@"; } || ( "$@" --help || "$@" -help ) 2>&1 | $paginate || which "$@";;
|
||||
esac
|
||||
docs="/usr/share/doc/$1"
|
||||
if test -d "$docs"; then
|
||||
|
|
|
@ -2,15 +2,16 @@
|
|||
# Remove recursively safely
|
||||
for f in "$@"
|
||||
do
|
||||
test -w "$f" && elevate="" || elevate=sudo
|
||||
if test -d "$f"; then
|
||||
if test -e "$f/.git" || test -e "$f/packed-refs"
|
||||
then echo -n "Force delete git project $f?"
|
||||
read answer
|
||||
test "$answer" = "y" && rm -rf "$f"
|
||||
test "$answer" = "y" && $elevate rm -rf "$f"
|
||||
else find "$f" -maxdepth 1 -type d -empty -printf "Removing empty %p\n" -delete
|
||||
test -e "$f" && echo -n "$f " >&2 && rm -rI "$f"
|
||||
test -e "$f" && echo -n "$f " >&2 && $elevate rm -rI "$f"
|
||||
fi
|
||||
else rm -i "$f"
|
||||
else $elevate rm -i "$f"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue