From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29407 invoked by alias); 14 May 2015 14:38:05 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20212 Received: (qmail 13404 invoked from network); 14 May 2015 14:38:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=TZG gVH4DOG50qPSpFLqR7JG8Wp0=; b=x8jM8+vTkmFWBupbjVM0qb/eWQIpfR4YsIc 3HnJw7N8nm5BMpScLeoQtq8D0gbqxQvP1RzlclpsHTRVCdAreQ0Wzu9UERNM6562 vJDON91wd+nM6/Nx9UiKIo8jy1hMYrM3Ook8540KKb1tlPTPeFakbB1ta3mYjmuM tegW0pBI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=TZ GgVH4DOG50qPSpFLqR7JG8Wp0=; b=PnIzaldkM3iTF7PiHiqyu22OQG6SYtusaL oM2KxOCc1d2vzIZGucgrbTJ4pEXgBjAwJppo1nzKTdjUzK1kJyoSVTwl7MAmoSn/ tBmRJOHjOACmQCsu2GgZJZ3nRilXJB6tTqVNyTLKdFyKesevmhx0u5nwx8J1idyP Wi7MSrOWk= X-Sasl-enc: VJlbX6yj9yTICdvV8EYn7tazTNTQe7ZX5d1DR3gQCIbt 1431614269 Date: Thu, 14 May 2015 14:37:47 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Add matchspec for foo/bar branch names in git completion Message-ID: <20150514143747.GF1932@tarsus.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) I'd like to add a matchspec to git heads completion, such that 'git checkout o/m' would complete to 'origin/master'. However, I can't seem to get the matchspec right. I tried this: [[[ diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 9304fbb..fe03439 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5585,7 +5585,7 @@ __git_remote_branch_names () { branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}#refs/remotes/}) __git_command_successful $pipestatus || return 1 - _wanted remote-branch-names expl 'remote branch name' compadd "$@" -a - branch_names + _wanted remote-branch-names expl 'remote branch name' compadd -M 'r:|/=*' "$@" -a - branch_names } (( $+functions[__git_remote_branch_names_noprefix] )) || @@ -5596,7 +5596,7 @@ __git_remote_branch_names_noprefix () { branch_names=(${${${(f)"$(_call_program remote-branch-refs-noprefix git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}##*/}:#HEAD}) __git_command_successful $pipestatus || return 1 - _wanted remote-branch-names-noprefix expl 'remote branch name' compadd "$@" -a - branch_names + _wanted remote-branch-names-noprefix expl 'remote branch name' compadd -M 'r:|/=*' "$@" -a - branch_names } (( $+functions[__git_commit_objects_prefer_recent] )) || @@ -5637,7 +5637,7 @@ __git_heads_local () { [[ -f $gitdir/refs/stash ]] && heads+=stash fi - _wanted heads-local expl "local head" compadd "$@" -a - heads + _wanted heads-local expl "local head" compadd -M 'r:|/=*' "$@" -a - heads } (( $+functions[__git_heads_remote] )) || @@ -5647,7 +5647,7 @@ __git_heads_remote () { heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)" refs/remotes' 2>/dev/null)"}) - _wanted heads-remote expl "remote head" compadd "$@" -a - heads + _wanted heads-remote expl "remote head" compadd -M 'r:|/=*' "$@" -a - heads } (( $+functions[__git_commit_objects] )) || ]]] Now, it does complete 'o/m' to 'origin/master', but when I type just 'or', it completes to 'origin', without the trailing slash: [[[ % git branch -l foo/a foo/b foo/c * master % git co fo % git co foo ]]] How could I get 'fo' to become 'foo/', with the slash? This is both in my usual config and in 'zsh -f'+compinit. Cheers, Daniel