X-Git-Url: http://git.iain.cx/?p=profile.git;a=blobdiff_plain;f=.profile.d%2Fp4.bashrc;h=081e89b549162f043e6dd09819cac4baf4b96a2e;hp=736d7e498f3e3a574c778d508224d744071e0d09;hb=a8e823fa2005ab190af0461c967f353b7dbb5a51;hpb=e082b7ddc9c8ad1fc763566b5e6bbd72b7ff26db diff --git a/.profile.d/p4.bashrc b/.profile.d/p4.bashrc index 736d7e4..081e89b 100644 --- a/.profile.d/p4.bashrc +++ b/.profile.d/p4.bashrc @@ -25,3 +25,30 @@ else export P4MERGE="p4merge" fi unset p4script p4vim + +# p4: Wrapper around p4 to add some other features. +function p4() { + if [ -z "$P4OPTSTRING" -a ! "${P4OPTSTRING+xxx}" = "xxx" ]; then + local p4=$(which p4) + P4OPTSTRING="$(strings $p4 | grep H:)" + fi + + local opts= + OPTIND=1 + if [ -n "$P4OPTSTRING" ]; then + while getopts "$P4OPTSTRING" opt; do + [ "$opt" = "?" ] && continue + opts="$opts -$opt $OPTARG" + done + shift $((OPTIND-1)) + fi + + command="$1"; shift + custom=${PROFILE_HOME:-~}/opt/p4/p4-"$command" + + if [ -x "$custom" ]; then + "$custom" $opts "$command" ${1+"$@"} + else + ( exec p4 $opts "$command" ${1+"$@"} ) + fi +}