automagical shell alias completion;
works with all common aliases, even self-aliases;
one completion function, for all aliases;
alias completion as easy as type-and-tab;
install dependency bash-completion;
bash-completionusing system package manager:
dnf install bash-completion ## fedora apt install bash-completion ## debian
bash-completionhomebrew formulae version 2:
brew install [email protected]
cat complete_alias >> ~/.bash_completion
add your own aliases in
for example, to complete aliases
complete -F _complete_alias foo complete -F _complete_alias bar complete -F _complete_alias baz
to complete an alias, type it and press
to complete alias
sctl aliased to
$ alias sctl='systemctl' $ echo "complete -F _complete_alias sctl" >> ~/.bash_completion $ sctl <tab> add-requires add-wants cancel cat condreload ...
support for gnu bash(>=4.4) on linux is aimed;
support for older versions of bash is uncertain;
support for other shells is possible but unlikely;
support for other operating systems is experimental;
how to install it on windows?
msys2 features pacman so you can install like linux:
pacman -S bash-completion cat complete_alias >> ~/.bash_completion
git for windows:
bash_completionand source it before
git for windows provides git bash, which is a minimal environment based on msys2; for what matters here, git bash does not have package manager; so the above install procedure does not apply;
the idea is, you must somehow get
bash-completionand load it before
complete-aliasin a shell environment; for example, you can download
bash-completionpackage from a msys2 mirror; however, the easiest solution i found to make things work is to simply download the main script
bash_completionfrom its git repo; this does not give you its entirety, but is good enough to work;
now you have 2 files:
complete_alias; you need to source them in this order in
. ~/.bash_completion.sh . ~/.complete_alias.sh
attention: here we renamed the files; we cannot use
~/.bash_completionbecause this is the very filename sourced by the very script; using this filename will cause an infinite loop;
now install is complete; add your own aliases in
The source code is licensed under the GNU General Public License v3.0.
Copyright (C) 2016-2018 Cyker Way
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.