2


I am trying to write a bash script to auto-complete my email address. So my goal is whenever I type foo in terminal and hit tab it completes it with [email protected].

So far I read these links:
https://unix.stackexchange.com/questions/1800/how-to-specify-a-custom-autocomplete-for-specific-commands?newreg=8f29593bf62a4dcb92c96c33219271fd https://debian-administration.org/article/317/An_introduction_to_bash_completion_part_2

But I couldn't achieve as both of them make auto-complete like foo [tab].
I'm sorry if I couldn't explain my question well but I don't want that space after foo.

Thanks in advance.

1 Answer 1

3

As far as I know, auto-completion is program in-depended. When you type command1 foo it looks specifically for command1's completion scripts and for command2 foo it looks for command2's completion scripts.

If you want your Email address a command it self and not an argument then:

$ touch ~/.local/bin/[email protected]
$ chmod +x ~/.local/bin/[email protected]

Make sure ~/.local/bin/ is in your PATH. Now:

pou[tab]

Completes it.

Another cool trick is to use aliases. Add a new alias like this:

alias 1='[email protected]'

Now type 1 then press Ctrl+Alt+e. Done.

2
  • That's correct. My solution was wrong from the beginning. Also, nice hack! Thanks. Apr 26, 2020 at 9:35
  • 1
    I've added another cool trick. Check it out you might like it. and you're welcome ;)
    – Ravexina
    Apr 26, 2020 at 11:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .