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
wrap more than just the command (e.g git checkout
)
#1976
Comments
Not yet. That looks for a command Today commands can only wrap other commands. The reason is that I wasn't sure how far to take it - can you also wrap commands with subcommands, redirections, unclosed quotes, etc? Taken to extremes you wind up with something like zsh's no-holds-barred global aliases. I think your use case is very reasonable. If you want to think through the issues and come up with a proposal for how it should behave, I'd sure appreciate it. An example of what I mean: what should You might also try an abbreviation here. |
yeah I found out about the abbreviations in a related issue. I tried them On Tue, Mar 10, 2015, 07:38 ridiculousfish notifications@github.com wrote:
|
Not yet. |
+1 for this issue. I'm former zsh user and trying to migrate to the fish shell, but blocked by this. I lived with tons of git aliases, and now I have serious problem with using them. I desperately need this feature. alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gb='git branch'
alias gba='git branch -a'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias gbs='git bisect'
... |
@simnalamburt You can use abbr -a g git |
@simnalamburt for aliases meant only for interactive use you're probably better served by the |
I used to make about 200 aliases. I tried to change all those aliases into https://github.com/simnalamburt/pkg-cgitc/blob/master/init.fish |
@simnalamburt: Too slow to start or slow while running? |
Too slow to start |
In that case, I've noticed abbr.fish taking a while. I'll try to take a look. |
@faho, nice. Try to open it in a new issue. |
@simnalamburt: You may want to try one of two things:
This is because abbreviations are stored in a universal (by default) variable shared among fish instances, so you don't need to set them up each time fish starts. You could also keep the calls in your config file but guard them with if set -q fish_initialized
set -U fish_initialized
abbr so wow
#...
end This is only a speedup of about 1/3 in the common case (abbrs already written) and depends on a git master fish (because of the |
git checkout
git checkout
)
@faho Thanks. Greatly settled with below: if not set -q cgitc_initialized
set -U cgitc_initialized
# Abbrs
end |
I think abbreviations are the right answer here - I don't know that there's much more to do. Thoughts? |
@zanchey: I don't think so. That wouldn't work for commands that wrap other commands, for one, and sometimes you have a function that can take the exact same arguments as something else, but you don't want it to show up fully in the commandline. |
For example, I have this function: function duthis
set -q argv[1]; or set argv * .*
du -sch $argv | sort -h
end Of course since the arguments are passed to (Currently, wrapping
@ridiculousfish: This is only about completions, right? Those aren't affected by redirections. Basically what I think would solve this completely is to use the argument to "--wraps" as the fake commandline and pass that to the completions, just like if |
The tricky part is that we have to figure out whose completion to invoke - for example, the |
Hi, I'm facing the same issue here. For a single abbr gwip 'git add -A; git rm (git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip-- [skip ci]"' |
Personally I recommend using an abbreviation for simple situations like the one in the original problem statement. This is the simplest solution to the problem and works well for me. For example, I have these git related abbreviations:
I can type any of them followed by a space and the subsequent completions work as expected. It is not at all clear how completions should work if the example by @inflation were instead an alias/function. |
I had created super fast git abbreviation plugin by hacking the Reference |
FWIW, I also would really like support for the "git checkout" case, except for a command that doesn't support aliases itself as git does. Abbreviations work, but are suboptimal because the expanded form is really verbose and ugly. |
As the person who opened this issue, I have to say that abbreviations seem to me better usability-wise. I've been using them since shortly after opening this issue and they have two main advantages:
|
@simnalamburt, Note that fish 3.0.0 will have much faster abbreviations. See issue #4048. That change, however, means that the |
I have an
My current approach is to clone the '### diff' section of https://github.com/fish-shell/fish-shell/blob/master/share/completions/git.fish into my own
Is this the cleanest way to do it? Or is there a cleaner way to inherit all the completions defined for |
That's probably as good as it gets. |
This enables some limited use of arguments for wrapping completions. The simplest example is that complete gco -w 'git checkout' now works like you would want: `gco <tab>` now invokes git's completions with the `checkout` argument prepended. Fixes fish-shell#1976
This should be working much better in bb7b649. Please give it a try and let me know if any aliases aren't behaving properly. |
I need git subcommands to autocomplete, but it's not working with aliases, so I've switched to abbreviations. For more details, see fish-shell/fish-shell#2277 (comment) fish-shell/fish-shell#1976
@ridiculousfish not sure if I should create a new issue or reply here... this doesn't seem to work with npm subcommands. For example |
@Siilwyn: Are you sure you are running fish 3.0.0? |
Sorry about that, I figured since this issue was closed a while ago I would be running a version that includes that fix but I'm still on 2.7. |
So now in fish 3.0.0 can I get
The closest I can get to it is a function that wraps it:
Thanks!
|
fish will complete aliases that only use internal git functions, but not those that start shell pipelines; your current method is probably the cleanest for now. |
Is this possible?:
I would expect this to auto complete like git checkout, though it does not.
The text was updated successfully, but these errors were encountered: