Last active
April 22, 2022 02:47
-
-
Save tlehman/c9d36df27f4f91386114acf03a1fd4f2 to your computer and use it in GitHub Desktop.
Go version manager in zsh using autocompletion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/zsh | |
# Go version manager by tlehman | |
# how to use: call _init_gvm in your .zshrc, then type "gvm -s <tab>" to have it autocomplete with all your installed go versions | |
function _gvm() { | |
local state | |
_arguments '-s[set go version]:go_version:->set_go' | |
case $state in | |
set_go) | |
for go_version in $(ls ~/sdk/); do | |
compadd $go_version | |
done | |
esac | |
} | |
function _init_gvm() { | |
# Bind your function to a command | |
compdef _gvm gvm # typing "gvm <tab>" will call gvm | |
} | |
if [ $# -eq 2 ]; then | |
echo "Setting Go version to $2" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WIP, this is the first time I've gotten zsh autocompletion to work