Search code examples
gitevernote

Format Git stdout to Evernote list items


I am using the following command:

git log --all --pretty="format:%s%w(0,8,8)%+b" | sed '/^$/d'

Which gives me the following output from git log.

Commit subject line
    Commit description line. This line can span
    multiple lines.
    Also new lines as well

When I paste this into my Evernote as list items it looks like the following.

  • Commit subject line
  •     Commit description line. This can span multiple lines.
  •     Also new lines as well.

I want to paste into Evernote but have the output look like the following.

  • Commit subject line
    • Commit description line. This can span multiple lines.
    • Also new lines as well.

Falling short on finding a way to accomplish this.


Solution

  • This is what I figured on Mac. It is not clean but you'll see what I've done.

    hex=`( echo "<ul>" && git log --all --pretty="format:<li>%s%w(0,8,8)<ul><li>%+b</li></ul></li>" | sed -e '/^$/d' -e 's|<ul><li></li></ul>||' && echo "</ul>" ) | hexdump -ve '1/1 "%.2x"'`
    osascript -e "set the clipboard to «data HTML${hex}»"
    

    After running the command above, you can paste it into Evernote.