日付ディレクトリhack
昔やって今も愛用しているlifehackを紹介-
~/Job/日付/ というディレクトリをその日のディレクトリにする。
-
一時的(その日でおわるもの、その日げっとしたもの)な作業や作文は分類せずにそのディレクトリにつっこむ
-
数日以上かかわるものは別のディレクトリに整理して置く。
-
で、それを支援するスクリプト。
-
.zshrc
-
tj (today's-jobdir) その日のディレクトリを出力します。
-
cj (chdir-to-jobdir) その日のディレクトリにcdします。
tj() {
dirname=~/Job/`date +'%Y%m%d'`
if [ ! -x $dirname ];
then
mkdir $dirname
fi
echo $dirname
}
cj() {
cd `tj`
}
.emacs.d/todaydir.el
-
関数 todaydir() その日のディレクトリを返します。
-
goto-todaydir その日のディレクトリに移動します(diredでひらきます C-x T)
-
insert-todaydir その日のディレクトリをカーソル位置に挿入します(C-x t)
(defun todaydir()
()
(format-time-string "~/Job/%Y%m%d/")
)
(defun goto-todaydir ()
(interactive)
(let*
((datedir (todaydir)))
(if (not (file-exists-p datedir))
(make-directory datedir)
)
(find-file datedir))
)
(defun insert-todaydir ()
(interactive)
(let*
((datedir (todaydir)))
(if (not (file-exists-p datedir))
(make-directory datedir)
)
(insert (todaydir))
)
)
(define-key ctl-x-map "T" 'goto-todaydir)
(define-key ctl-x-map "t" 'insert-todaydir)
使う様子
-
なんかメモを書くとき emacsで C-x C-f C-x t hogememo.txt で、その日のディレクトリが勝手にできてhogememo.txt を編集
-
なんかダウンロードしたい時
dragon:~$ cj dragon:~/Job/20060829$ wget http://hogehuga...
-
なんか出力をファイルに残したいとき
dragon:~/Src/xen/foobar$ ./foobar > `tj`/output.txt
