cleanup wdotd first, then create new

This commit is contained in:
Jakobus Schürz 2020-01-22 12:47:14 +01:00
parent d4c7138667
commit 1646d79a58

View file

@ -99,7 +99,19 @@ if [ $(id -u) -ne 0 ]; then
ARCHIVPATH="${HOME}/${ARCHIVSUBPATH}"
WDOTD=$(date "+${ARCHIVPATH}/%Y/%m/work_%Y%m%d")
WORKDIR="${HOME}/Work"
# First cleanup all empty Archivdirectories for workdir
for i in $(find ${ARCHIVPATH} -type d); do
if [ ! "$(ls -A $i)" ]; then
echo "DIR $i is empty -> remove it"
echo rm -rf "$i"
fi
done
# Create workdir of the day, if not existing
[ -e $WDOTD ] || mkdir -pv "${WDOTD}" >>${MYSHELLCONFIG_LOGFILE}
# Link $WORKDIR to $WDOTD and set alias
if [[ ( -e "${WORKDIR}" && -h "${WORKDIR}" ) || ! -e "${WORKDIR}" ]] ; then
ln -svnf "${WDOTD}" "${WORKDIR}" >>${MYSHELLCONFIG_LOGFILE}
alias gowork='cd "${WORKDIR}"'
@ -108,12 +120,7 @@ if [ $(id -u) -ne 0 ]; then
alias gowork='echo "${WORKDIR} is not configurable, see ${MYSHELLCONFIG_LOGFILE}'
fi
for i in $(find ${ARCHIVPATH} -type d); do
if [ ! "$(ls -A $i)" ]; then
echo "DIR $i is empty -> remove it"
echo rm -rf "$i"
fi
done
unset ARCHIVPATH ARCHIVSUBPATH
fi