diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-05-29 13:05:03 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-05-31 08:58:45 -0700 |
commit | 0a39fb2ab65dfdbfbf8022cfdfc3975eba7ac6f2 (patch) | |
tree | 6b810bdcb9e6c569d3d0bcf6e9eb906653e14566 /org.eclipse.jgit.pgm | |
parent | 8d1ac7a769b3fc4725537376e0e14d3b96ebbe3d (diff) | |
download | jgit-0a39fb2ab65dfdbfbf8022cfdfc3975eba7ac6f2.tar.gz jgit-0a39fb2ab65dfdbfbf8022cfdfc3975eba7ac6f2.zip |
jgit.sh: Implement pager support
If the command is either `diff` or `log`, there is often a lot of
lines of output. Run these commands through $GIT_PAGER, $PAGER, or
`less` in order to make it easier to browse the output on a terminal.
Change-Id: I18b87ea4acf404b94788f2ac2101812bd13e6a0f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/jgit.sh | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/org.eclipse.jgit.pgm/jgit.sh b/org.eclipse.jgit.pgm/jgit.sh index e6a2119ef1..9ff59d6122 100644 --- a/org.eclipse.jgit.pgm/jgit.sh +++ b/org.eclipse.jgit.pgm/jgit.sh @@ -41,6 +41,20 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +cmd= +for a in "$@" +do + case "$a" in + -*) continue ;; + *) cmd=$a; break; ;; + esac +done + +use_pager= +case "$cmd" in +diff) use_pager=1 ;; +log) use_pager=1 ;; +esac this_script=`which "$0" 2>/dev/null` [ $? -gt 0 -a -f "$0" ] && this_script="$0" @@ -58,7 +72,7 @@ CYGWIN*) cp=`cygpath --windows --mixed --path "$cp"` ;; Darwin) - if test -e /System/Library/Frameworks/JavaVM.framework + if [ -e /System/Library/Frameworks/JavaVM.framework ] then java_args=' -Dcom.apple.mrj.application.apple.menu.about.name=JGit @@ -74,10 +88,25 @@ CLASSPATH="$cp" export CLASSPATH java=java -if test -n "$JAVA_HOME" +if [ -n "$JAVA_HOME" ] then java="$JAVA_HOME/bin/java" fi -exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@" -exit 1 +if [ -n "$use_pager" ] +then + use_pager=${GIT_PAGER:-${PAGER:-less}} + [ cat = "$use_pager" ] && use_pager= +fi + +if [ -n "$use_pager" ] +then + LESS=${LESS:-FSRX} + export LESS + + "$java" $java_args org.eclipse.jgit.pgm.Main "$@" | $use_pager + exit +else + exec "$java" $java_args org.eclipse.jgit.pgm.Main "$@" + exit 1 +fi |