--- /dev/null
+#!/bin/bash
+set -e
+
+defshow=' '
+showopt () {
+ eval "showopt_$1=$2"
+}
+defshow () {
+ showopt $1 $2
+ eval "defshow+='$2 '"
+}
+defshow B --branches
+defshow R --remotes
+showopt T --tags
+showopt A --all
+
+opts=()
+
+getshowopt () {
+ eval "showopt=\$showopt_$1"
+}
+
+while [ $# -ge 1 ]; do case "$1" in
+
+ +) shift; defshow=''; break ;; # disable defshow
+
+ --)
+ # remaining args are paths, but we want default showing
+ break
+ ;;
+ -*)
+ # some gitk option, stop parsing
+ # user may have to say + to disable default showing
+ break
+ ;;
+
+ +*)
+ arg="$1"; shift
+ while true; do
+
+ case "$arg" in
+
+ +[BRTA]*)
+ getshowopt ${arg:1:1}
+ defshow=''; opts+=($showopt)
+ ;;
+ +-[BRTA]*)
+ getshowopt ${arg:2:1}
+ defshow="${defshow/ $showopt / }"
+ arg="${arg#+-?}"; continue
+ ;;
+
+ +d*) opts+=(--date-order) ;;
+ +f*) opts+=(--first-parent) ;;
+
+ +) break ;;
+
+ *) echo >&2 "gitk wrapper: unknown + option $arg"
+ exit 127
+ ;;
+
+ esac
+
+ arg="+${arg#+?}"
+ done
+ ;;
+
+ *) defshow=''; break ;; # some instruction to gitk
+
+ esac
+done
+
+set -x
+exec /usr/bin/gitk "${opts[@]}" $defshow "$@"