Skip to content

Instantly share code, notes, and snippets.

@suzuki-kei
Created November 9, 2014 10:03
Show Gist options
  • Save suzuki-kei/8d8f584a7bed9b9f036f to your computer and use it in GitHub Desktop.
Save suzuki-kei/8d8f584a7bed9b9f036f to your computer and use it in GitHub Desktop.
memo と打つと ~/.memo/memo.YYYY-MM-DD.txt というファイルを作成し、$EDITOR で開いてくれる Bash スクリプトです。ファイルは daily でバックアップされます。
function memo {
local memo_dir=~/.memo
mkdir -p "$memo_dir"
local current_memo_file=$memo_dir/memo.`date '+%Y-%m-%d'`.txt
local previous_memo_file=$memo_dir/`ls -1 "$memo_dir" | tail -1`
if [ ! -f "$current_memo_file" -a -f "$previous_memo_file" ]; then
cp -pi "$previous_memo_file" "$current_memo_file"
fi
$EDITOR $current_memo_file
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment