Add the clean command.
Sometimes it is useful to remove temporary files from a directory. I used to do this with a shell script located in /usr/bin/, however that wasn't very convenient. Putting the script in the .zshrc allows to maintains the very small script with all the dotfiles instead of copying the script from machines to machines.
This commit is contained in:
parent
c4671585e3
commit
7b89640777
1 changed files with 25 additions and 0 deletions
25
.zshrc
25
.zshrc
|
@ -81,3 +81,28 @@ if hash dig 2>/dev/null; then
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
clean()
|
||||||
|
{
|
||||||
|
clean_dir()
|
||||||
|
{
|
||||||
|
local dir="$1"
|
||||||
|
if [ -d "$dir" ]; then
|
||||||
|
find "$dir" -name "*~" -print -delete
|
||||||
|
find "$dir" -name ".*~" -print -delete
|
||||||
|
find "$dir" -name "#*#" -print -delete
|
||||||
|
else
|
||||||
|
echo "$dir: not a directory"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $# -ne 0 ]; then
|
||||||
|
for dir in "$@"; do
|
||||||
|
clean_dir "$dir"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
clean_dir "./"
|
||||||
|
fi
|
||||||
|
|
||||||
|
unfunction clean_dir
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue