New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alias completion #393
Comments
see also #165 |
It may be simpler to add an argument to the 'function' builtin, that allows you to specify that the function 'completes like'. Alias can then provide this argument by default. An example:
would result in
The completer then will just virtually substitute 'git push' for gp when it needs to. This may be simpler than parsing the function body every time |
@stestagg the way what it will be done is left to the creator, but I also think that manually setting completition is better than parsing body function. But using |
An argument to the function builtin would be enough for all cases, and would have the benefit of being defined in the same place as the function which needs it. The |
I just found out about this "missing feature" as well.
This won't auto-complete the available branches/tags, which is really a shame. To implement this myself I had to c/p the relevant parts from |
This is a big one for me, too. |
For the love of all that is fishy, make it so! |
Before alias completion is supported you can use this function to produce alias completion: function make_completion --argument-names alias command
echo "
function __alias_completion_$alias
set -l cmd (commandline -o)
set -e cmd[1]
complete -C\"$command \$cmd\"
end
" | .
complete -c $alias -a "(__alias_completion_$alias)"
end use it as follows: |
Or another implementation, without creating intermediate function. It can be added to the 'alias' definition. function make_completion --argument alias command
complete -c $alias -a "(
set -l cmd (commandline -op);
set -e cmd[1];
complete -C\"$command \$cmd\";
)"
end |
Wonderful! This is how I've used it:
On Thu, Jan 24, 2013 at 03:06:52AM -0800, maxfl wrote:
|
It is almost great except that if I alias
this still doesn't work. |
I see. The problem is that 'commandline -o' looses the trailing space. Here is the solution. function make_completion --argument alias command
complete -c $alias -xa "(
set -l cmd (commandline -pc | sed -e 's/^ *\S\+ *//' );
complete -C\"$command \$cmd\";
)"
end Since now we do not split the commandline output, we have to use sed to replace the command. I've also changed '-a' to '-xa' option, because the filename completions should be added by nested 'complete' command. |
Does anyone have any thoughts on how One possibility would be to make
Within the completion, Another possibility is to replace the ad-hoc use of commandline with true subcommand support (so you could write a completion specifically for 'git branch'). |
Maybe we should check out how ZSH does it? It's able to complete things like shell aliases as well as aliases set in |
@ridiculousfish, there is another way to look at it: it's not an issue of the 'commandline', but an issue of the 'complete':
|
However you solve this I'd like it if the solution works also for functions, not just aliases. @maxfi's suggestion in the comment above would seem to qualify, for example. Making |
BTW if this becomes a reality we also need a way to escape it. Consider |
Just migrated to fish from zsh and that issue is now bothering me. |
I agree that this should be a feature of Also @maxfl's |
I think that #731 would fix this. |
Having aliases automatically expand as I type (as per the abbreviations feature in #731) would be a huge turn-off. I'm very sensitive to anything that changes what I'm typing out from under me. |
Note that abbreviations only expand when you hit enter or space. Try it and you might be surprised at how non-invasive it actually is. Or maybe you're not impressed at all – people are different! I certainly do think we need some way to "redirect" completions, regardless of aliases and abbreviations. This should probably be a feature of |
I'm not keen on this at all, bash does something similar with tilda Thanks Steve On Fri, Nov 1, 2013 at 10:53 AM, Dag Odenhall notifications@github.comwrote:
|
+1 |
complete --command egrep --like grep
complete --command egrep --erase --short-option E --long-option extended-regexp Just thinking. Needs better name than |
For me |
@dag "Function signature" is a misnomer. I should have called it command signature. You can set one on a function in its declaration, on external commands, and builtins will have them too. |
This is a real must! For me, the tab completion is the killer feature of fish, but I need to be able to easily add it to my aliases (functions).#393 (comment) works for me. |
This is really something where For an example see the completion for All of the completion files for these tools just call If you take a look into This could be easily solved with a |
+1. Feature is critical for me as well. |
+1. This is also very important to me, it bothers me to have to write the full command name. Btw other things from fish are very cool : ) |
+1. That's the only thing I miss since moving from (oh-my)-zsh |
+1. The |
This is implemented as 06400b8. The commit message has more details. In short you can now do this:
or
Either way, I went with I didn't implement support for aliasing to multiple commands, i.e. Definitely interested in your suggestions or ideas for improvements here. |
So basically there is still no way to have things like |
Next time you write |
It would be great if the abbreviations could be seamless (i.e. not expand when entered) |
That is pretty much the point with the abbreviations though, you could just create a function wrapper if you want to keep it unexpanded. I find it much more clear and useful when it expands, barely have any aliases anymore. |
But you can't then get completions wrapped if you do, so the feature looses On Tue, Aug 26, 2014 at 7:10 PM, Terje Larsen notifications@github.com
|
@terlar Thanks, that works. It's somewhat an undocumented feature (found more info in the issue tracker). |
It's an incomplete feature - we don't have any real UI for it yet (either in fish_config or command line). |
For people wondering about git aliases, I can say that it works if you set your alias in .gitconfig instead of in fish configuration. |
Thanks! This is very convenient! Worth building |
This does not seem to solve the issue when you've abbreviated Using
does not help, and using
gives you completions for
(Rambling, hope it's helpful) |
Correct, abbreviations only support the token in command position - see #1976 for some discussion. |
It will be nice if we can make completion work for aliases too. I.e.
And now everything that will be completed in
git <tab>
will work also ing <tab>
.The text was updated successfully, but these errors were encountered: