alias f='git flow feature'
complete -F __git_flow_feature f
它的工作原理,最終(後2「標籤」),但每個「標籤」按拋出一個錯誤。
-bash: [: 1: unary operator expected
任何想法?
alias f='git flow feature'
complete -F __git_flow_feature f
它的工作原理,最終(後2「標籤」),但每個「標籤」按拋出一個錯誤。
-bash: [: 1: unary operator expected
任何想法?
它的工作對我來說,當我這樣做:
總之,對於最常見的原因「[1:一元運算符預期」錯誤是,你必須像shell腳本代碼:
if [ 1 = $MYVAL ]
和你MYVAL
未設置。檢查你的完成功能。您可以添加set -x
進行調試。
通常情況下,最簡單的解決方法是引用變量,以便操作者將得到空的說法,但將有正確數量的參數:
if [ 1 = "$MYVAL" ]
我也有這個問題,每一個谷歌搜索導致我回這個帖子。
我張貼,我發現使用米哈爾的答案,並Daenyth的評論的解決方案......
我的混帳flow.bash是相同的,但我認爲我們的git完成文件可能不同。
爲了解決這個問題,我不得不改變我的混帳完成文件位於/etc/bash_completion.d/git
老:
# __git_find_on_cmdline requires 1 argument
__git_find_on_cmdline()
{
local word subcommand c=1
while [ $c -lt $cword ]; do
word="${words[c]}"
for subcommand in $1; do
if [ "$subcommand" = "$word" ]; then
echo "$subcommand"
return
fi
done
c=$((++c))
done
}
新:
# __git_find_on_cmdline requires 1 argument
__git_find_on_cmdline()
{
local word subcommand c=1
while [[ $c -lt $cword ]]; do
word="${words[c]}"
for subcommand in $1; do
if [ "$subcommand" = "$word" ]; then
echo "$subcommand"
return
fi
done
c=$((++c))
done
}
注意雙支架我不得不添加到新代碼。這是我做的唯一改變。
還沒有爲我工作,仍然有同樣的錯誤[:1:一元運算符預期 – decebal 2014-01-14 10:31:01
爲什麼不只是使用git-flow-completion?對於慶典的指令是:
$ cd /etc/bash_completion.d
$ sudo wget https://raw.githubusercontent.com/bobthecow/git-flow-completion/master/git-flow-completion.bash
$ exec $SHELL
我有這個別名:
alias gn="git-number"
alias gb="gn -c git blame"
alias ge="gn -c $EDITOR"
alias ga="gn add"
alias gr="gn -c git reset"
alias gap="EDITOR='$EDITOR -w' gn add -p"
alias gd="gn -c git diff -b -w --ignore-blank-lines"
alias gds="gd --staged"
alias gc="gn -c git checkout"
alias gcf="git flow feature checkout"
alias gl="gn -c git log -w -b -p --ignore-blank-lines"
alias gls="git log --stat"
alias cm="EDITOR='$EDITOR -w' git commit"
alias grb="git stash save 'REBASE' && EDITOR='$EDITOR -w' git rebase -i"
alias grbc="EDITOR='$EDITOR -w' git rebase --continue"
gcd() {
test -n "$1" && cd $(dirname $(git list $1))
}
source ~/.git-completion.bash
__git_complete gn _git
__git_complete ga _git_add
__git_complete gap _git_add
__git_complete gd _git_diff
__git_complete gds _git_diff
__git_complete gc _git_checkout
__git_complete gcf _git_checkout
__git_complete gl _git_log
__git_complete gls _git_log
__git_complete cm _git_commit
source ~/.git-flow-completion.bash
而作爲安裝completion
腳本:
wget -O ~/.git-completion.bash https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
wget -O ~/.git-flow-completion.bash https://raw.githubusercontent.com/petervanderdoes/git-flow-completion/develop/git-flow-completion.bash
Git的數量注意這裏是:https://github.com/holygeek/git-number 就在回購複製二進制文件~/bin
因爲它是慶典,使用'[['而不是'['。這更聰明 – Daenyth 2012-01-17 15:46:31