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 # Remove directory by removing subdirectories up a level
dedir(){ 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) name=$(uuidgen)
# Move it to a random name without clobbering, this prevents things like # Move the directory to the uuid
# files/files =mv -n "$1" "$name" || return 1
# From erroring because you can't move files/files to . # Move all files, use (N) in case there is no * or .* matches
chronic mv -n "$1" "$name" || return 5 =mv -n "$name"/{.,}*(N) . || return 2
chronic mv "$name"/*(D) . =rmdir "$name" || return 3
chronic rmdir -v "$name"
} }
alias afci='git x ./autoformat.sh;git add --all;git commit -m "Autoformatted"' alias afci='git x ./autoformat.sh;git add --all;git commit -m "Autoformatted"'
alias eix="eix -F" alias eix="eix -F"