Skip to content

Instantly share code, notes, and snippets.

@kaz-utashiro
Last active September 16, 2020 19:14
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 kaz-utashiro/b7ef5b11619a0a8c0a46dcb3335b44c1 to your computer and use it in GitHub Desktop.
Save kaz-utashiro/b7ef5b11619a0a8c0a46dcb3335b44c1 to your computer and use it in GitHub Desktop.
Word や PowerPoint のファイルを grep したり diff したりする ref: https://qiita.com/kaz-utashiro/items/30594c16ed6d931324f9
option default --mecab
[diff "msdoc"]
command = optex --exit 0 diff --msdoc -u --git-external-diff
option --pandoc \
--if '/\.docx$/:pandoc -f docx -t plain'
option --tika \
--if '/\.(docx|pptx|xlsx)$/:tika --text'
export BRIGHTNESS=0
option --light --cmy
option --dark --dark-cmy
*.docx diff=msdoc
*.pptx diff=msdoc
*.xlsx diff=msdoc
option --msdoc -Mmsdoc $<move>
option default --msdoc
$ greple -Mmsdoc 経費 kisairei.docx
$ greple -Mmsdoc '経費 換算' kisairei.docx
$ grep 経費 <(greple -Mmsdoc --dump kisairei.docx)
$ diff <(greple -Mmsdoc --dump kisairei-H{25,26}.docx)
$ grep --msdoc -e 経費 -e 換算 kisairei.docx
$ optex grep --msdoc 経費 kisairei.docx
$ optex diff kisairei-H25.docx kisairei-H26.docx
$ alias diff="optex diff -Mmsdoc"
$ git config --global diff.msdoc.textconv "greple -Mmsdoc --dump"
$ git config --global diff.msdoc.textconv "greple -Mmsdoc --dump"
$ git config --global diff.msdoc.command "optex --exit 0 diff --msdoc -u --git-external-diff"
$ greple -Mmsdoc -e 経費 -e 換算 kisairei.docx
$ git config --global diff.msdoc.command "optex --exit 0 diff --msdoc -u --git-external-diff"
$ brew cpanminus
$ curl -sL http://cpanmin.us | perl - App::cpanminus
$ curl -sL http://cpanmin.us | perl - App::cpanminus
$ cpanm App::optex::msdoc
$ cpanm App::optex::msdoc
export LESS=-cR
export LESSANSIENDCHARS=mK
$ cpanm App::sdif
$ cpanm App::sdif
$ greple -Mmsdoc '経費 換算 -物品調達' kisairei.docx
$ greple -Mmsdoc -e 経費 -e 換算 -v 物品調達 kisairei.docx
option --light --cmy
option --dark --dark-cmy
export BRIGHTNESS=0
$ greple -Mmsdoc '\A' --all kisairei.docx
$ LESSOPEN="| greple -Mmsdoc --dump %s" less kisairei.docx
$ optex less --ms kisairei.docx
$ optex --ln less
$ less --ms kisairei.docx
option --ms -Mutil::setenv(LESSOPEN="| greple -Mmsdoc --dump %s")
option --msx -Mutil::setenv(LESSOPEN="| greple -Mmsdoc --dump --indent %s")
##
## GIT_EXTERNAL_DIFF is called with 7 parameters:
## path old-file old-hex old-mode new-file new-hex new-mode
## 0 1 2 3 4 5 6
##
option --git-external-diff $<copy(1,1)> $<copy(4,1)> $<remove>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment