Created
May 28, 2014 16:30
-
-
Save jewel12/fb1e53f319a37b11a988 to your computer and use it in GitHub Desktop.
メモの中にファイル名とカテゴリを書いておくとカテゴリ名のディレクトリを作って勝手にcpしてくれるやつをとりあえず
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard :shell do | |
watch 'tmp.md' do |f| | |
lines = open(f.first).readlines | |
file_name = $~[1] if lines.any?{ |l| l =~ /^__(.+)__$/ } | |
category = $~[1] if lines.any?{ |l| l =~ /^\[(.+)\]$/ } | |
if file_name && category | |
FileUtils.mkdir_p(category) | |
FileUtils.cp 'tmp.md', category + '/' + file_name | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment