Comments (2)
This is essentially what the completions for sudo or env do.
In principle, what you need to do is to get mytool run python
to complete like python
- to do that, you need to run complete -C python
.
So, you need to grab the commandline, and remove "mytool run" from it.
Fish has the __fish_complete_subcommand helper function for this, and in the simplest case this would be
complete --command mytool -n "__fish_seen_subcommand_from run" -a '$(__fish_complete_subcommand --fcs-skip=2)'
where the "--fcs-skip=2" tells it to skip two tokens from the commandline - that's "mytool" and "run".
If your tool has e.g. options that come before the "run" this gets more complicated, see the sudo completions and the __fish_sudo_print_remaining_args
helper function for how to do that.
Your attempt here has two issues:
- Because
"$(complete -C)"
is double-quoted, thecomplete -C
will be run when the completions are loaded. That means if you attempt to complete something else, it will be stuck on the initial commandline complete -C
reruns completions on the entire current commandline (it's the implied default if you don't give it a "fake" commandline to operate on)
from fish-shell.
Aha! This is absolutely perfect.
I also learnt a lot about fish generates completions -- the explanation for how this comes together (I just spent a bit of time fiddling with __fish_complete_subcommand
to see how it works) was super useful.
Thank you so much, I really appreciate the help.
from fish-shell.
Related Issues (20)
- [vi-mode] Allow different fish_sequence_key_delay_ms for different bind modes HOT 1
- Fish should expand abbreviations after an `env` command HOT 3
- feature request: support full CSIu kitty keyboard protocol HOT 1
- Test failures pre 3.8.0 HOT 7
- Configure `backward-kill-path-component` to count `-` as a separator? HOT 3
- Add an easy way to retry a command until it succeeds HOT 1
- Undenied permission with brew? HOT 8
- Fish git prompt doesn't show (U)pdated but (U)nmerged changes HOT 2
- No $status even though it's reported it exists HOT 2
- fish_history corrupted with NUL bytes HOT 1
- Oh, I have to pass the argument with quotes, I see. But this one is not working for me HOT 1
- fish_variables has too large size make fish has a significant delays during startup HOT 1
- Different descriptions of Universal variables in the documentation HOT 1
- Transient prompt doesn't work on recent git master builds
- Terminal protocols spew a *lot* of output
- Android install tutorial in README.md HOT 1
- Alias escaping HOT 1
- Feat: In commands such as `edit_command_buffer` set an environment variable to let the editor config setup custom behaviour HOT 3
- Paging command output as if it was written to a terminal HOT 2
- fish became slow because checking two tools HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fish-shell.