How do you make an alias or function that retains tab completion?

labyrinth

I made an alias to save some keystrokes with working with systemd:

$ alias sctl='systemctl'

However, this breaks tab completion for the subcommands. Is it possible to alias a command without breaking tab completion?

chaos

First find out which complete-function is used for the systemctl command:

complete | grep " systemctl$"

The output looks like this:

complete -F _functionname systemctl

Then use:

complete -F _functionname sctl

To register the function for the completion of your alias.

Now, when you type sctl <tab><tab>, the same suggestions as when you type systemctl will appear.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do you use <TAB> to cycle through completion suggestions with ALE?

How can I make tab completion for my Git alias behave like an existing command?

How do I view the tab completion function for a command in bash?

Tab completion for alias in OSX

How to make bash completion work for git alias?

How do I make Vim do normal (Bash-like) tab completion for file names?

How do I make bash do vim-like tab completion for file names?

How do you wrap executable commands so that they work in an alias or function?

Tab completion on mosh (ssh) alias?

How can you convert this bash completion function to a zsh completion function?

How do I make a working emacs alias function?

How do you alias a type?

How do I find out which function is used for zsh tab completion

How to make an alias of a function/procedure?

How do you convert a library function with two completion handlers into an async function?

How do I make a function wait for the completion of another function before running

In Swift, how do you loop through a list and hand one item at a time to a function with completion closure?

Tab completion for alias with the same names in zsh

How to make tab completion append slash for directory symlinks?

How do you alias a type iny Python?

How do you make a function detect whether a string is binary safe or not

How do you make the CreateFileA WINAPI function work in this form?

How do you make a function that uses keywords in racket

How do you make a function accept multiple types?

How do you make a code run after a callback function in Angular?

How do you make a function using the if command for a range of values on R

How do you make a shell function that you can pipe into to make the output red?

Eclipse tab completion deletes code - How do I prevent it?

How do I add tab completion to the Python shell?