diff options
author | 2011-09-23 14:51:14 +0400 | |
---|---|---|
committer | 2011-09-23 14:51:14 +0400 | |
commit | 39a2fd1717dc69b9f4643bb6a2060713c2e5f636 (patch) | |
tree | 85d83318b572c9a141879a9ce6d547c56237116e | |
parent | c66ec4df3d57bcbd8eb1fb3d92c3cd80e1c215b5 (diff) |
* git rm and git status options are added
* ssh subcomand completion
* __fish_complete_subcommand now can skip variable number of tokens
-rw-r--r-- | share/completions/git.fish | 15 | ||||
-rw-r--r-- | share/completions/ssh.fish | 5 | ||||
-rw-r--r-- | share/functions/__fish_complete_subcommand.fish | 16 |
3 files changed, 29 insertions, 7 deletions
diff --git a/share/completions/git.fish b/share/completions/git.fish index 6350513a..df6d045d 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -196,11 +196,24 @@ complete -f -c git -n '__fish_git_needs_command' -a revert -d 'Revert an existin # TODO options ### rm -complete -c git -n '__fish_git_needs_command' -a rm -d 'Remove files from the working tree and from the index' +complete -c git -n '__fish_git_needs_command' -a rm -d 'Remove files from the working tree and from the index' +complete -c git -n '__fish_git_using_command rm' -f +complete -c git -n '__fish_git_using_command rm' -l cached -d 'Keep local copies' +complete -c git -n '__fish_git_using_command rm' -l ignore-unmatch -d 'Exit with a zero status even if no files matched' +complete -c git -n '__fish_git_using_command rm' -s r -d 'Allow recursive removal' +complete -c git -n '__fish_git_using_command rm' -s q -l quiet -d 'Suppress the output' +complete -c git -n '__fish_git_using_command rm' -s f -l force -d 'Override the up-to-date check' +complete -c git -n '__fish_git_using_command rm' -s n -l dry-run -d 'Dry run' # TODO options ### status complete -f -c git -n '__fish_git_needs_command' -a status -d 'Show the working tree status' +complete -f -c git -n '__fish_git_using_command status' -s s -l short -d 'Give the output in the short-format' +complete -f -c git -n '__fish_git_using_command status' -s b -l branch -d 'Show the branch and tracking info even in short-format' +complete -f -c git -n '__fish_git_using_command status' -l porcelain -d 'Give the output in a stable, easy-to-parse format' +complete -f -c git -n '__fish_git_using_command status' -s z -d 'Terminate entries with NUL character' +complete -f -c git -n '__fish_git_using_command status' -s u -l untracked-files -x -a 'no normal all' -d 'The untracked files handling mode' +complete -f -c git -n '__fish_git_using_command status' -l ignore-submodules -x -a 'none untracked dirty all' -d 'Ignore changes to submodules' # TODO options ### tag diff --git a/share/completions/ssh.fish b/share/completions/ssh.fish index 5cbaacff..aada35e0 100644 --- a/share/completions/ssh.fish +++ b/share/completions/ssh.fish @@ -15,9 +15,9 @@ complete -x -c ssh -d Hostname -a " " complete -x -c ssh -d User -a " - (__fish_print_users)@ " +complete -c ssh --description "Command to run" -x -a '(__fish_complete_subcommand --fcs-skip=2)' complete -c ssh -s a --description "Disables forwarding of the authentication agent" complete -c ssh -s A --description "Enables forwarding of the authentication agent" @@ -46,3 +46,6 @@ complete -c ssh -s X --description "Enable X11 forwarding" complete -c ssh -s L --description "Locally forwarded ports" complete -c ssh -s R --description "Remotely forwarded ports" complete -c ssh -s D --description "Dynamic port forwarding" + +# Since ssh runs subcommands, it can accept any switches +complete -c ssh -u diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index c002b812..885b0544 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -1,14 +1,20 @@ function __fish_complete_subcommand -d "Complete subcommand" + set -l skip_next 1 + switch "$argv[1]" + case '--fcs-skip=*' + set -l rest + echo $argv[1] | tr = ' ' | read test skip_next + set -e argv[1] + end set -l res "" set -l had_cmd 0 set -l cmd (commandline -cop) (commandline -ct) - set -l skip_next 1 for i in $cmd - if test "$skip_next" = 1 - set skip_next 0 + if test $skip_next -gt 0 + set skip_next (expr $skip_next - 1) continue end @@ -17,15 +23,15 @@ function __fish_complete_subcommand -d "Complete subcommand" else if contains -- $i $argv - set skip_next 1 + set skip_next (expr $skip_next + 1) continue end switch $i case '-*' case '*=*' - case '*' + set had_cmd 1 set res $i end |