0
我正在爲Hub寫一個完成腳本。抑制魚殼中的文件名/目錄完成
這是我的第一個完成腳本,我遇到了一些問題。從git.fish完成劇本獲得靈感,這裏是我到現在爲止:
# statement starting with 'hub'
function __fish_hub_needs_command
set cmd (commandline -opc)
if [ (count $cmd) -eq 1 -a $cmd[1] = 'hub' ]
return 0
end
return 1
end
# statement starting with 'hub COMMAND'
function __fish_hub_using_command
set cmd (commandline -opc)
if [ (count $cmd) -gt 1 ]
if [ $argv[1] = $cmd[2] ]
return 0
end
end
return 1
end
# help
# show '--help' for every command
complete -f -c hub -n '__fish_hub_needs_command' -a help -d 'Display enhanced git-help(1)'
complete -f -c hub -n 'not __fish_hub_needs_command' -l help -d 'Display enhanced git-help(1)'
# alias
complete -f -c hub -n '__fish_hub_needs_command' -a alias -d 'Shows shell instructions for wrapping git.'
complete -f -c hub -n '__fish_hub_using_command alias' -s s -d 'Output shell script suitable for eval.'
現在,當型hub <tab>
它顯示我help
和alias
正確地補全。但是在輸入hub alias <tab>
後,即使我在那裏提供了-f
選項,它也會顯示我的目錄列表。
這裏有什麼問題?爲什麼會發生?有沒有辦法在這種情況下禁止文件/目錄完成?
幫助將不勝感激。謝謝。