Comments (5)
The last two sentences of your commit leave a lot to be desired.
They basically say "use this completely uncommented master-level bash function." All the user wants, and all I want to do, is use a predefined completion for an alias.
The only way I can see that is either to put a symlink of the alias name under the completions directory--that requires root, while aliases are defined per-user--or just load the completion first in the shell, defeating the point of the dynamic loading you've set up.
How do I register an alias or my own custom function or command for dynamic completion loading? Or is that not possible. And can you explain that with an example that does not require root?
from bash-completion.
The git completion is not shipped by us, it comes with git itself, and this doesn't look like an issue with bash-completion or related aliases in the first place. But anyway, here's some ideas you may find useful: The function git uses may not be named _git
, you can check what it is with complete -p git
(for me it's __git_wrap__git_main
). Also, if your git completion is not eagerly loaded at shell startup, you need to ensure it gets loaded on demand when your own completion that uses it is invoked. There are a couple of ways to do this; one is to use our _xfunc
helper function, and another is to place appropriately named symlink in your bash-completion's completions
dir. See examples in bash-completion for these for more info.
from bash-completion.
i think i wasn't clear on this. this isnt specific to git. it happens with all aliases, i just used git as an example.
when typing git <tab>
i get the correct git completion output.
here my output: note the second gitalias
test@test:~$ complete -p git
bash: complete: git: no completion specification
test@test:~$ gitalias bash: completion: function '_git' not found`
test@test:~$ git
add config log reset
am credential meld revert
annotate describe merge rm
apply diff mergetool shortlog
archive difftool mv show
bisect fetch name-rev show-branch
blame filter-branch notes stage
branch format-patch pull stash
bundle fsck push status
checkout gc rebase submodule
cherry get-tar-commit-id reflog subtree
cherry-pick grep relink tag
clean help remote verify-commit
clone imap-send repack whatchanged
column init replace
commit instaweb request-pull
test@test:~$ gitalias
add config log reset
am credential meld revert
annotate describe merge rm
apply diff mergetool shortlog
archive difftool mv show
bisect fetch name-rev show-branch
blame filter-branch notes stage
branch format-patch pull stash
bundle fsck push status
checkout gc rebase submodule
cherry get-tar-commit-id reflog subtree
cherry-pick grep relink tag
clean help remote verify-commit
clone imap-send repack whatchanged
column init replace
commit instaweb request-pull
test@test:~$ complete -p git
complete -o bashdefault -o default -o nospace -F __git_wrap__git_main git
after reading your answer this looks like the completion is not loaded at shell startup. How can i achieve this?
my bashrc should already do it, i think, as it contains
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
what gets shipped with debian
But i will look through your other ideas as soon as i get off work. thanks
EDIT:
adding _completion_loader git
does the trick. Thanks for pointing me in the right direction!
But for complete -p git
to work i still need to trigger the completion at least once. I can live with that...
from bash-completion.
The last two sentences of my previous comment already contained pointers towards how to take care of this the recommended way, dynamically. Direct invocation of _completion_loader
could work too, but it's not intended to be used like that.
from bash-completion.
User completion files are dynamically loaded from $BASH_COMPLETION_USER_DIR/completions
. See the source of __load_completion
for what the user dir defaults to.
from bash-completion.
Related Issues (20)
- Hard to find where to report bugs HOT 2
- Latest CHANGELOG.md starts at `## 2.11...` and earlier HOT 2
- Redirection moved to the front wrongly affects completions HOT 2
- Gentoo update to 2.14 fails due to QA notice HOT 3
- tar file completion not working as expected under various option combinations HOT 2
- Enable .java Filename Completion for java Command HOT 2
- GCC tests fail on non-x86 platforms HOT 1
- CDPATH autocomplete is not working HOT 5
- 000_bash_completion_compat.bash sourced last in some locales HOT 1
- bash: _comp_initialize: command not found HOT 2
- [Regression] make autocompletion skips install HOT 3
- Native bash-completion 2 loader using complete -D HOT 5
- Completing a relative path with a space and softlinks inside, turns it absolute (which breaks creating relative softlinks) HOT 1
- Completions for 'alternatives' command are broken HOT 1
- xspec is ignored when Bash option `force_fignore` is unset HOT 5
- [2.14.0] rsync path completion fails if a folder name have a space
- Completions are not loaded in Linux+Homebrew HOT 2
- Feature request: generalized implementation of `_comp_command_offset` HOT 12
- File ~/.bash_completion no longer working after update to 2.14. HOT 2
- Hi, i need help regarding bash-completion. HOT 1
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 bash-completion.