better go support

This commit is contained in:
Loic Nageleisen 2014-10-14 15:21:12 +02:00
parent c393dca551
commit 101a9c7a77
2 changed files with 9 additions and 4 deletions

View file

@ -1,4 +1,4 @@
go_commands=(go)
go_commands=(go vim)
_go-installed() {
which go > /dev/null 2>&1
@ -21,13 +21,13 @@ _within-go-project() {
_run-with-gopath() {
local go_path
if _go-installed && go_path=$(_within-go-project); then
GOPATH="$go_path" $@
env PATH="$PATH:$go_path/bin" GOPATH="$go_path" "$@"
else
$@
"$@"
fi
}
for cmd in ${go_commands[@]}; do
for cmd in "${go_commands[@]}"; do
eval "function gopath_$cmd () { _run-with-gopath $cmd \$@; }"
alias $cmd=gopath_$cmd
@ -37,3 +37,5 @@ for cmd in ${go_commands[@]}; do
fi
fi
done
# vim: ft=sh

View file

@ -6,6 +6,9 @@ NODE_PATH=/usr/local/lib/node
export NODE_PATH
PATH=$PATH:/usr/local/share/npm/bin
# go
PATH=$PATH:/usr/local/opt/go/libexec/bin
# no emoji
HOMEBREW_NO_EMOJI="you bet"
export HOMEBREW_NO_EMOJI