So I turned to "Uncle Google" :P for it. Also what I remembered from Zsh is that it's auto completion is really awesome. So I searched for "zsh autocomplete function" and read some stackoverflow examples and stuff. But I had some errors if I was using oh-my-zsh's functions.zsh to store/write my zsh auto complete function in it.
What I did was, instead of writing that auto complete function inside oh-my-zsh's functions.zsh, I wrote it directly inside .zshrc, like this;
function prog() {
cd ~/Programming/Pythons/$1;
}
_prog() {
_files -W ~/Programming/Pythons;
}
compdef _prog prog
What this code actually does is that when you type
This exactly did what I needed. If you got awesome auto complete functions written, do share it at the comments. :)
prog
after sourcing your .zshrc file, it expands the defined directory, in here; '~/Programming/Pythons/' and the argument $1 is based on whatever directory you selected from the expansion of the directory from the function _prog()
, like this;
source [1]: http://stackoverflow.com/questions/10700012/zsh-autocomplete-function-based-on-2-arguments
source [2]: https://wiki.archlinux.org/index.php/Zsh#Command_Completion
No comments:
Post a Comment