From 06a0963b01117d27f5975f8fbe306f8807cd4cc7 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 19 Feb 2009 03:05:33 +0100 Subject: [PATCH] Check own name for command When zit is invoked with a different name than zit, it will issue its own name as command. This is especially useful with the newly introduced zig and zik commands to call tig and gitk respectively. --- zit | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/zit b/zit index 449246c..f653dd1 100755 --- a/zit +++ b/zit @@ -5,15 +5,20 @@ abort() { exit 1 } -cmd="$1" -shift +me="$(basename $0)" +if test "$me" = zit ; then + cmd="$1" + shift +else + cmd="$me" +fi USAGE="usage: zit COMMAND FILE [ARGS...]" zit_help() { cmd="$1" shift - case $cmd in + case "$cmd" in git) git help "$@" ;; @@ -56,6 +61,14 @@ zit_help() { echo "" echo "See 'zit help git' or 'git help' for git commands." ;; + zig) + echo "usage: zig FILE" + echo "Browse FILE's history with tig." + ;; + zik) + echo "usage: zik FILE" + echo "Browse FILE's history with gitk." + ;; esac } @@ -152,11 +165,11 @@ zit_import() { git add -f $1 } -case $cmd in +case "$cmd" in "") echo $USAGE ;; - help) + help|--help|-h|-?) zit_help "$@" ;; init|track) @@ -184,6 +197,16 @@ case $cmd in shift "$@" ;; + zig) + zit_setup $1 + shift + tig "$@" + ;; + zik) + zit_setup $1 + shift + gitk "$@" + ;; # Most commands will work with the generic catch-all mechanism used # below, but some of them require a more thorough analysis of the # parameters to decide whether $ZIT_FILE should be put back into the -- 2.32.0.93.g670b81a890