5

Tip #310   Keeping your Home Directory Organized

Seen on http://www.splitbrain.org/blog/2008-02/27-keeping_your_home_directory_organized

Having one temporary directory for downloads etc can quickly become a mess, so try this tip to organise by date. Put this into your .bashrc


export TD="$HOME/temp/`date +'%Y-%m-%d'`"
td(){
td=$TD
if [ ! -z "$1" ]; then
td="$HOME/temp/`date -d "$1 days" +'%Y-%m-%d'`";
fi
mkdir -p $td; cd $td
unset td
}


You'll receive a new function 'td' for making temp-dirs under $HOME/temp/ named by date. It is also possible to switch days back with 'td -[n]', i. e. 'td -3' which means '3 days back from now'.