Great changes in dedir

This commit is contained in:
Austen Adler 2016-06-26 21:16:19 -04:00
parent 2d44e18fe7
commit b33680e04a
No known key found for this signature in database
GPG Key ID: 7ECEE590CCDFE3F1

View File

@ -56,14 +56,17 @@ dsl() {
}
# Remove directory by removing subdirectories up a level
dedir(){
chronic rmdir "$1" -v && return
# Try removing the directory if it's empty, fail silently if you can't
=rmdir "$1" 2>/dev/null && return
# Make a uuid to avoid name conflicts
# Ex: dediring sage when sage/sage fails because sage/sage is moved to .
# but since sage/ exists, it can't be moved
name=$(uuidgen)
# Move it to a random name without clobbering, this prevents things like
# files/files
# From erroring because you can't move files/files to .
chronic mv -n "$1" "$name" || return 5
chronic mv "$name"/*(D) .
chronic rmdir -v "$name"
# Move the directory to the uuid
=mv -n "$1" "$name" || return 1
# Move all files, use (N) in case there is no * or .* matches
=mv -n "$name"/{.,}*(N) . || return 2
=rmdir "$name" || return 3
}
alias afci='git x ./autoformat.sh;git add --all;git commit -m "Autoformatted"'
alias eix="eix -F"