bin: adjust bak to auto-elevate
This commit is contained in:
parent
f8d4fc9b4c
commit
79be21761e
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# [b]rowse - custom ls or bat depending on file type
|
# [b]rowse - custom ls or bat depending on file type
|
||||||
# Show type & contents of given files or PWD
|
# Show type & contents of given files or PWD
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
suffix="${2:-bak}"
|
suffix="${2:-bak}"
|
||||||
orig="${1%%.$suffix}"
|
orig="${1%%.$suffix}"
|
||||||
|
smv () {
|
||||||
|
test -w "$1" && mv -v "$@" || sudo mv -v "$@"
|
||||||
|
}
|
||||||
if test -e "$orig.$suffix"
|
if test -e "$orig.$suffix"
|
||||||
then
|
then
|
||||||
test -e "$orig" && mv -v "$orig" /tmp
|
test -e "$orig" && smv "$orig" /tmp
|
||||||
mv -vn "$orig.$suffix" "$orig"
|
smv -n "$orig.$suffix" "$orig"
|
||||||
else mv -vn "$1" "$1.$suffix"
|
else smv -n "$1" "$1.$suffix"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue