Closed akefirad closed 3 years ago
You didn't find it because I never tested it on ZSH, or any other terminal except bash.
Ok. After initial tests, it almost works and requires these fixes:
Currently, it adds bash completion lines like the below to the ~/.bash_aliases
script
complete -W "pull build" docker
I need to find what is the alternative in ZSH for one-liner completions, and change it when using ZSH.
In addition, the aliases are stored in ~/.bash_aliases
, which is automatically sourced by typical login scripts. I am assuming it is not sourced in ZSH, right? If not, then users either need to add the source line manually, or I need to create the equivalent file for ZSH (I am guessing ~/.zsh_aliases?).
About aliases, according to this and this it should be as easy as add .bashrc
and .bash_aliases
to .zshrc
. But not sure about completion. Would you please kindly test and make it official? I also can help with testing if you tell me what exactly needs to be verified (just to make sure we're not missing anything). Thanks.
Sure thing, I think I found the way.
I just found out in this answer a way to make the simple bash completion lines also work in ZSH. I just need to add these two lines before running the complete
commands:
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
and it seems to be working.
I will work on it tomorrow and hopefully make it work, and would appreciate your help verifying (since I am running it inside a dockerized Alpine ZSH).
Just ping me, when you need me to verify.
Ok - there is an initial attempt in #32.
In order to test it, you need to:
alf
and the sample alf.conf
from the new branch (links already do that)../alf g
to see that alf itself works (it will just output the aliases to stdout)./alf save
and it will save it in your ~/.bash_aliases
, which you can then source ~/.bash_aliases
and have the sample aliases defined and with autocompletion for subcommands.@akefirad I think the pull request is ready. What is left is "real world" verification.
I changed it a little since my previous comment, so if you already tested, it would be great if you can test again.
Waiting for your input.
Sorry for the late reply. So I followed your instruction. Everything works as you said with the sample alf.conf
. However when I tried alf connect akefirad
(it's based on your template), it generates a ~/.bash_aliases
that when sourced in ZSH, fails with
/Users/rad/.bash_aliases:604: parse error near `()'
Looking at the aliases file, it seems the logic to generate repeat
alias it not right:
unalias repeat 1>/dev/null 2>&1
repeat() {
for i in `seq $1`; do ${@:2} ; done
}
If I comment this out, the rest of aliases seem to work just fine.
Excellent!
Yes, I also noticed that repeat
cannot be aliased in ZSH.
I also commented it out from my own personal repo (which happens to be the template).
I might need to separate the template from my personal repo (although this would be difficult, since the repo name alf-conf
has meaning).
Thanks for opening this issue and testing it, I am closing and releasing a version.
Please feel free to comment here, or open other issues (or questions) if any arise.
Awesome, thanks for the awesome tool mate!
@akefirad - by the way, in the future, if you want to delete an alias, you should not edit the ~/.bash_aliases
file. You should simply delete (or comment) it from the config file and run alf save
again.
I couldn't find this anywhere. Is this compatible with ZSH? Thanks.