config/shell: Add mvf and smv shell function

This commit is contained in:
xerus2000 2020-10-14 19:00:08 +02:00
parent 87b000c390
commit 83f4a5cbed
1 changed files with 11 additions and 1 deletions

View File

@ -217,7 +217,17 @@ alias f1='find -mindepth 1 -maxdepth 1'
which perl-rename >/dev/null && alias lowercase='perl-rename "y/A-Z/a-z/"' || alias lowercase='rename "y/A-Z/a-z/"'
mkcd() {
mkdir -p $1 && cd $1
mkdir -p "$1" && cd "$1"
}
# mv with automatic sudo if neccessary
smv() {
test -w "$1" && test -w "$(dirname $2)" && mv "$@" || sudo mv "${@}"
}
# Rename the file, keep it in its directory
mvf() {
smv "$1" "$(dirname $1)/$2"
}
# Creates directory $2 and moves $1 into it