Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

Vinllen Chen


但行好事,莫问前程

源码查看神器OpenGrok

  MAC/Linux下,vim+各种插件对于大规模代码还是不行,网上找了个神器OpenGrok可以查看。
  2017_08_16 Update:文章末尾提到的insight.io是一款更加优秀的源码阅读工具。
1. 首先安装java环境:jre,jdk。
2. 安装tomacat
brew install tomcat 3. 安装ctags
brew install ctags 4. 下载OpenGrok
wget -O - http://java.net/projects/opengrok/downloads/download/opengrok-0.12.1.tar.gz | tar xvz 5. 在tomcat上部署
OPENGROK_TOMCAT_BASE=/usr/local/Cellar/tomcat/8.0.17/libexec opengrok-0.12.1/bin/OpenGrok deploy 6. 查看是否安装成功
catalina start open http://localhost:8080/source 7. 打开代码
OPENGROK_INSTANCE_BASE=opengrok-0.12.1 opengrok-0.12.1/bin/OpenGrok index /path/to/your/source 8. 关闭
catalina stop

打开关闭有点麻烦,搞个脚本:

#!/bin/bash 

err="parameter error, opengrok start path/stop"

if [[ $# -lt 1 || $# -gt 2 ]]  
then  
    echo $err
    exit 1
elif [ $# == 1 ]  
then  
    if [ $1 != "stop" ]
    then
        echo $err
        exit 1
    fi
    catalina stop
elif [ $# == 2 ]  
then  
    if [ $1 != "start" ]
    then
        echo $err
        exit 1
    fi
    catalina start
    open http://localhost:8080/source
    OPENGROK_INSTANCE_BASE=opengrok-0.12.1 /Users/vinllen/opt/opengrok-0.12.1/bin/OpenGrok index $2
fi  

  另外,insight.io也是另外一款相当不错的源码阅读软件,包括语法高亮、语义调整、语法提示灯,除了文本编辑以外极度类似一个IDE,亲测好用,大家可以试试。

参考

https://opengrok.github.io/OpenGrok/
http://blog.simplypatrick.com/2015/01/16/opengrok-on-mac-osx/
https://insight.io/

说明

转载请注明出处:http://vinllen.com/yuan-ma-cha-kan-shen-qi-opengrok/


About the author

vinllen chen

Beijing, China

格物致知


Discussions

comments powered by Disqus