EmJames

Search

Search IconIcon to open search

Zsh alias with argument and autocompletion

Last updated Feb 18, 2020

After trying different alias types (such as in this and this) I was unable to add an alias with an argument that also worked with autocompletion. Perhaps I skimmed through too quickly. Regardless, I solved this issue as follows:

1
alias openb='openb(){ xdg-open $1 &! }; openb'

I went through the Zsh docs on functions and tried different approaches and none of them worked with autocompletion. If you could be kind enough to email (ej at this-site-dot-com) or message me in regards the reason of this working, I would appreciate it very much.

This worked on:

1
2
3
4
$ cat /etc/fedora-release
Fedora release 31 (Thirty One)
$ /bin/zsh --version
zsh 5.7.1 (x86_64-redhat-linux-gnu)