使用emacs或vim的命令行程序的语法荧光笔? [英] Utilizing emacs' or vim's syntax highlighter for command-line program?
问题描述
Matthew Wozniski写了一个名为vimcat.sh的脚本,它与Vim一起使用。他的版本是 https://github.com/godlygeek/vim -files /斑点/主/宏/ vimcat.sh 。我已经做了一些修改(如果内存服务,这些修改允许它在我的Mac OS X系统上运行;我知道替换为 / dev / fd / 9
为 / proc / self / fd / 9
有此目的);请参阅 https://gist.github.com/4090959 上的要点。
如果Vim的突出显示改变背景,我相信脚本的两个版本都有麻烦返回默认的背景颜色。
I have a command-line program that spews JSON and YAML. By default it detects if pygments (pygmentize) is available and if it does, pass the output throught it to get a nice colorized output. However, pygments is not installed by default on most computers that this program will run on. But most computers will have either emacs or vim, however, does. Is there a way to get one of these editors to syntax-highlight some text using ANSI escape sequences and then output it again?
Matthew Wozniski wrote a script called vimcat.sh that does this with Vim. His version is at https://github.com/godlygeek/vim-files/blob/master/macros/vimcat.sh. I've made a few modifications to it (if memory serves, the modifications allowed it to run on my Mac OS X system; I know the substitution of /dev/fd/9
for /proc/self/fd/9
had that purpose); see my gist at https://gist.github.com/4090959.
I believe both versions of the script have trouble with returning to default background color if Vim's highlighting changes the background.
这篇关于使用emacs或vim的命令行程序的语法荧光笔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!