[Wilds] Update "arc shell-complete" for toolsets
Summary:
Ref T13098. Major changes:
`arc shell-complete` now installs itself to your `~/.profile`. Running `arc shell-complete` again will update the hook and update the completion rules.
Completion rules work for all toolsets, so you can install once and then autocomplete in `arc`, `phage`, etc.
This code supports other shells in theory, and I developed most of it with ZSH support next to the Bash support. However, while actually testing ZSH support, I couldn't get it to even slightly work and found myself falling down a very, very deep rabbit hole of ZSH being entirely written in bash script and `${0:a:h}` being a legitimate script construction. The existing ZSH support comes from one guy in 2012 and also does not work for me on `master`, so I ultimately removed it. Open to restoring it but I wasn't able to figure it out in 10 minutes of Googling and I'm not convinced it's worth 11 minutes of Googling.
I left a few rough edges here with notes on how to improve/fix them, but the basics all work.
Test Plan:
- Ran `arc shell-complete` under various stages of `~/.profile`, couldn't get it to do anything bad.
- Ran `arc lib<tab>`, `arc shell-complete --curr<tab>`, etc. Got sensible suggestions and completions.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13098
Differential Revision: https://secure.phabricator.com/D19700
2018-09-21 22:09:20 +02:00
|
|
|
_arcanist_complete_{{{BIN}}} ()
|
2011-01-15 05:00:11 +01:00
|
|
|
{
|
|
|
|
COMPREPLY=()
|
[Wilds] Update "arc shell-complete" for toolsets
Summary:
Ref T13098. Major changes:
`arc shell-complete` now installs itself to your `~/.profile`. Running `arc shell-complete` again will update the hook and update the completion rules.
Completion rules work for all toolsets, so you can install once and then autocomplete in `arc`, `phage`, etc.
This code supports other shells in theory, and I developed most of it with ZSH support next to the Bash support. However, while actually testing ZSH support, I couldn't get it to even slightly work and found myself falling down a very, very deep rabbit hole of ZSH being entirely written in bash script and `${0:a:h}` being a legitimate script construction. The existing ZSH support comes from one guy in 2012 and also does not work for me on `master`, so I ultimately removed it. Open to restoring it but I wasn't able to figure it out in 10 minutes of Googling and I'm not convinced it's worth 11 minutes of Googling.
I left a few rough edges here with notes on how to improve/fix them, but the basics all work.
Test Plan:
- Ran `arc shell-complete` under various stages of `~/.profile`, couldn't get it to do anything bad.
- Ran `arc lib<tab>`, `arc shell-complete --curr<tab>`, etc. Got sensible suggestions and completions.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13098
Differential Revision: https://secure.phabricator.com/D19700
2018-09-21 22:09:20 +02:00
|
|
|
|
|
|
|
CUR="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
OPTS=$(echo | {{{BIN}}} shell-complete --current ${COMP_CWORD} -- ${COMP_WORDS[@]} 2>/dev/null)
|
2011-11-10 01:37:32 +01:00
|
|
|
|
2011-01-15 05:00:11 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
return $?
|
|
|
|
fi
|
2011-11-10 01:37:32 +01:00
|
|
|
|
2011-01-15 05:00:11 +01:00
|
|
|
if [ "$OPTS" = "FILE" ]; then
|
|
|
|
COMPREPLY=( $(compgen -f -- ${CUR}) )
|
|
|
|
return 0
|
|
|
|
fi
|
2011-11-10 01:37:32 +01:00
|
|
|
|
2011-01-15 05:00:11 +01:00
|
|
|
if [ "$OPTS" = "ARGUMENT" ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
2011-11-10 01:37:32 +01:00
|
|
|
COMPREPLY=( $(compgen -W "${OPTS}" -- ${CUR}) )
|
2011-01-15 05:00:11 +01:00
|
|
|
}
|
[Wilds] Update "arc shell-complete" for toolsets
Summary:
Ref T13098. Major changes:
`arc shell-complete` now installs itself to your `~/.profile`. Running `arc shell-complete` again will update the hook and update the completion rules.
Completion rules work for all toolsets, so you can install once and then autocomplete in `arc`, `phage`, etc.
This code supports other shells in theory, and I developed most of it with ZSH support next to the Bash support. However, while actually testing ZSH support, I couldn't get it to even slightly work and found myself falling down a very, very deep rabbit hole of ZSH being entirely written in bash script and `${0:a:h}` being a legitimate script construction. The existing ZSH support comes from one guy in 2012 and also does not work for me on `master`, so I ultimately removed it. Open to restoring it but I wasn't able to figure it out in 10 minutes of Googling and I'm not convinced it's worth 11 minutes of Googling.
I left a few rough edges here with notes on how to improve/fix them, but the basics all work.
Test Plan:
- Ran `arc shell-complete` under various stages of `~/.profile`, couldn't get it to do anything bad.
- Ran `arc lib<tab>`, `arc shell-complete --curr<tab>`, etc. Got sensible suggestions and completions.
Reviewers: amckinley
Reviewed By: amckinley
Maniphest Tasks: T13098
Differential Revision: https://secure.phabricator.com/D19700
2018-09-21 22:09:20 +02:00
|
|
|
complete -F _arcanist_complete_{{{BIN}}} -o filenames {{{BIN}}}
|