tag:blogger.com,1999:blog-6112936277054198647.post8652141031456301027..comments2024-03-12T00:42:06.642+10:00Comments on Who-T: Daily tmp directoryPeter Huttererhttp://www.blogger.com/profile/17204066043271384535noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6112936277054198647.post-5895250368048283962012-07-14T02:31:52.037+10:002012-07-14T02:31:52.037+10:00Here's a similar solution that I've been u...Here's a similar solution that I've been using for a few years (placed in my .zshrc file). Type 't' to jump to today's temp directory, 'tp' to print the directory (useful for redirecting logs), and e.g. 't 2' to jump to the directory from the day before yesterday.<br /><br />(Blogger is going to butcher the indenting.)<br /><br /># Switch to temporary directories.<br />temp_dir() {<br /> local base=$1<br /> local gothere=$2<br /> local worldreadable=$3<br /> local create=1<br /> if test "$4"; then<br /> if echo "$4" | egrep -q '^[0-9]+$' && test $4 -gt 0; then<br /> local dir=$base/$(date -d "$4 days ago" +%Y%m%d)<br /> local create=0<br /> else<br /> local dir="$base/$4"<br /> fi<br /> else<br /> local dir=$base/$(date +%Y%m%d)<br /> fi<br /><br /> if [[ $create == 1 ]] && test \! -e "$dir"; then<br /> mkdir -p "$dir"<br /> if [[ $worldreadable == 1 ]]; then<br /> chmod 755 "$dir"<br /> fi<br /> fi<br /><br /> if [[ $gothere == 1 ]]; then<br /> cd $dir<br /> else<br /> echo $dir<br /> fi<br />}<br />t() { temp_dir $HOME/temp 1 0 $1; }<br />tp() { temp_dir $HOME/temp 0 0 $1; }Daniel Erathttps://www.blogger.com/profile/13320957163729425518noreply@blogger.comtag:blogger.com,1999:blog-6112936277054198647.post-56798774859598162282012-07-12T06:17:41.504+10:002012-07-12T06:17:41.504+10:00If you use the polyinstantion namespace feature in...If you use the polyinstantion namespace feature in pam_namespace - you should be able to have your system automatically do this tmpdir creation for you.skvidalhttps://www.blogger.com/profile/00993961635850065167noreply@blogger.com