gimme plugin: Initial commit
This commit is contained in:
parent
d848c94804
commit
cb54391572
21
plugins/gimme/LICENSE
Normal file
21
plugins/gimme/LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2017 Thomas Goldbrunner
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
17
plugins/gimme/README.md
Normal file
17
plugins/gimme/README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
### Gimme plugin for oh-my-zsh
|
||||||
|
|
||||||
|
[Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh/) plugin making life a
|
||||||
|
bit easier, when you use [gimme](https://github.com/travis-ci/gimme/) to manage
|
||||||
|
[go](https://golang.org) installations.
|
||||||
|
|
||||||
|
Provides following functions/aliases:
|
||||||
|
- ```go-versions```: Alias for ```gimme -l```
|
||||||
|
- ```install-gimme```: Download latest version of gimme to ~/bin
|
||||||
|
- ```load-go```: Load the go version specified by the first argument.
|
||||||
|
If called without argument, the 'stable' version will be loaded.
|
||||||
|
- ```remove-go```: Remove the go version specified by the first argument from
|
||||||
|
~/.gimme/*
|
||||||
|
- Completions for ```gimme``` and ```load-go```
|
||||||
|
|
||||||
|
```gimme``` is assumed to be in ```~/bin```, so make
|
||||||
|
sure to add this folder to the $PATH variable.
|
117
plugins/gimme/gimme.plugin.zsh
Normal file
117
plugins/gimme/gimme.plugin.zsh
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
# Load a go version.
|
||||||
|
# If no version is provided, 'stable' will be loaded.
|
||||||
|
load-go() {
|
||||||
|
# check if gimme is available (unfortunately eval does not return a non-zero
|
||||||
|
# value if the command is not found, therefore we need to check before)
|
||||||
|
gimme &>/dev/null
|
||||||
|
if [[ $? == 127 ]] ; then
|
||||||
|
echo "gimme was not found in your PATH.
|
||||||
|
Run install-gimme and make sure to add ~/bin to your PATH."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ "$#" == 0 ]] ; then
|
||||||
|
eval "$(gimme stable)"
|
||||||
|
else
|
||||||
|
eval "$(gimme ${*})"
|
||||||
|
fi
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
# alias for gimme -l
|
||||||
|
alias go-versions='gimme -l'
|
||||||
|
|
||||||
|
# download latest version of gimme
|
||||||
|
install-gimme() {
|
||||||
|
if ! [ -d ~/bin ] ; then
|
||||||
|
mkdir ~/bin || return 1
|
||||||
|
fi
|
||||||
|
curl -sL -o ~/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
|
||||||
|
chmod +x ~/bin/gimme || return 1
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# remove go version from ~/.gimme/*
|
||||||
|
remove-go() {
|
||||||
|
if [[ "$#" != 1 ]] ; then
|
||||||
|
echo "Usage: remove-go GO_VERSION"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
if [ "$1" = "stable" ] ; then
|
||||||
|
if ! [ -e ~/.gimme/versions/stable ] ; then
|
||||||
|
echo "go version stable is not installed"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
version="$(cat ~/.gimme/versions/stable)" || return 1
|
||||||
|
rm ~/.gimme/versions/stable || return 1
|
||||||
|
else
|
||||||
|
version="$1"
|
||||||
|
fi
|
||||||
|
if ! [ $(ls ~/.gimme/versions | grep "$version") ] ; then
|
||||||
|
echo "go version $version is not installed"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
rm -r ~/.gimme/versions/go"$version"* || return 1
|
||||||
|
rm ~/.gimme/envs/go"$version"* || return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# gimme completion
|
||||||
|
__gimme_completion() {
|
||||||
|
local version_1 version_2 version_3
|
||||||
|
version_1="1.8.3"
|
||||||
|
version_2="1.7.6"
|
||||||
|
version_3="1.6.4"
|
||||||
|
local context state state_descr line
|
||||||
|
typeset -a go_versions
|
||||||
|
go_versions+=(
|
||||||
|
'(help version force list tip '$version_1' '$version_2' '$version_3' \
|
||||||
|
)stable[install latest stable go version]'
|
||||||
|
'(help version force list stable '$version_1' '$version_2' '$version_3' \
|
||||||
|
)tip[install development version (master branch) of go]'
|
||||||
|
'(help version force list stable tip '$version_2' '$version_3' \
|
||||||
|
)'$version_1'[install go version '$version_1']'
|
||||||
|
'(help version force list stable tip '$version_1' '$version_3' \
|
||||||
|
)'$version_2'[install go version '$version_2']'
|
||||||
|
'(help version force list stable tip '$version_1' '$version_2' \
|
||||||
|
)'$version_3'[install go version '$version_3']'
|
||||||
|
)
|
||||||
|
typeset -a flags
|
||||||
|
flags+=(
|
||||||
|
'(version force list stable tip '$version_1' '$version_2' \
|
||||||
|
'$version_3')help[show help text and exit]'
|
||||||
|
'(help force list stable tip '$version_1' '$version_2' \
|
||||||
|
'$version_3')version[show the gimme version only and exit]'
|
||||||
|
'(help version list)force[remove the existing go installation if present prior to install]'
|
||||||
|
'(help version force stable tip '$version_1' '$version_2' \
|
||||||
|
'$version_3')list[list installed go versions and exit]'
|
||||||
|
)
|
||||||
|
_values -w 'flags go_versions' ${flags[@]} ${go_versions[@]}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
__load-go_completion() {
|
||||||
|
local version_1 version_2 version_3
|
||||||
|
version_1="1.8.3"
|
||||||
|
version_2="1.7.6"
|
||||||
|
version_3="1.6.4"
|
||||||
|
local context state state_descr line
|
||||||
|
typeset -a go_versions
|
||||||
|
go_versions+=(
|
||||||
|
'(tip '$version_1' '$version_2' '$version_3' \
|
||||||
|
)stable[latest stable go version]'
|
||||||
|
'(stable '$version_1' '$version_2' '$version_3' \
|
||||||
|
)tip[development version (master branch) of go]'
|
||||||
|
'(stable tip '$version_2' '$version_3' \
|
||||||
|
)'$version_1'[go version '$version_1']'
|
||||||
|
'(stable tip '$version_1' '$version_3' \
|
||||||
|
)'$version_2'[go version '$version_2']'
|
||||||
|
'(stable tip '$version_1' '$version_2' \
|
||||||
|
)'$version_3'[go version '$version_3']'
|
||||||
|
)
|
||||||
|
_values 'go_versions' ${go_versions[@]}
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef __gimme_completion gimme
|
||||||
|
compdef __load-go_completion load-go
|
Loading…
Reference in New Issue
Block a user