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:
Rodolphe Breard 2015-11-02 22:02:04 +01:00
parent c4671585e3
commit 7b89640777

25
.zshrc
View file

@ -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
}