Skip to content

Instantly share code, notes, and snippets.

@jewel12
Created May 28, 2014 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jewel12/fb1e53f319a37b11a988 to your computer and use it in GitHub Desktop.
Save jewel12/fb1e53f319a37b11a988 to your computer and use it in GitHub Desktop.
メモの中にファイル名とカテゴリを書いておくとカテゴリ名のディレクトリを作って勝手にcpしてくれるやつをとりあえず
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