cleanup wdotd first, then create new
This commit is contained in:
parent
d4c7138667
commit
1646d79a58
1 changed files with 13 additions and 6 deletions
|
@ -99,7 +99,19 @@ if [ $(id -u) -ne 0 ]; then
|
||||||
ARCHIVPATH="${HOME}/${ARCHIVSUBPATH}"
|
ARCHIVPATH="${HOME}/${ARCHIVSUBPATH}"
|
||||||
WDOTD=$(date "+${ARCHIVPATH}/%Y/%m/work_%Y%m%d")
|
WDOTD=$(date "+${ARCHIVPATH}/%Y/%m/work_%Y%m%d")
|
||||||
WORKDIR="${HOME}/Work"
|
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}
|
[ -e $WDOTD ] || mkdir -pv "${WDOTD}" >>${MYSHELLCONFIG_LOGFILE}
|
||||||
|
|
||||||
|
# Link $WORKDIR to $WDOTD and set alias
|
||||||
if [[ ( -e "${WORKDIR}" && -h "${WORKDIR}" ) || ! -e "${WORKDIR}" ]] ; then
|
if [[ ( -e "${WORKDIR}" && -h "${WORKDIR}" ) || ! -e "${WORKDIR}" ]] ; then
|
||||||
ln -svnf "${WDOTD}" "${WORKDIR}" >>${MYSHELLCONFIG_LOGFILE}
|
ln -svnf "${WDOTD}" "${WORKDIR}" >>${MYSHELLCONFIG_LOGFILE}
|
||||||
alias gowork='cd "${WORKDIR}"'
|
alias gowork='cd "${WORKDIR}"'
|
||||||
|
@ -108,12 +120,7 @@ if [ $(id -u) -ne 0 ]; then
|
||||||
alias gowork='echo "${WORKDIR} is not configurable, see ${MYSHELLCONFIG_LOGFILE}'
|
alias gowork='echo "${WORKDIR} is not configurable, see ${MYSHELLCONFIG_LOGFILE}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for i in $(find ${ARCHIVPATH} -type d); do
|
unset ARCHIVPATH ARCHIVSUBPATH
|
||||||
if [ ! "$(ls -A $i)" ]; then
|
|
||||||
echo "DIR $i is empty -> remove it"
|
|
||||||
echo rm -rf "$i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue