mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-21 18:46:06 +02:00
* Create go_prompt_info to add go version to prompts * golang: move go_prompt_info to plugin, guard and quote output Addresses review feedback: the prompt helper only belongs to Go developers, so it moves out of lib/ (sourced for every shell) into plugins/golang/golang.plugin.zsh. Adds a $+commands[go] guard so users without Go installed don't spawn a process or see a stderr error on every prompt render, quotes the version output the same way the rvm/nvm helpers do so a % can't be read as a prompt escape, and adds the dummy go_prompt_info stub to lib/prompt_info_functions.zsh for themes that call it when the plugin isn't loaded. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193G8TyNqmNnv6v9HsVafGa --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1.0 KiB
Bash
48 lines
1.0 KiB
Bash
## completion
|
|
compctl -g "*.go" gofmt # standard go tools
|
|
compctl -g "*.go" gccgo # gccgo
|
|
|
|
# gc
|
|
for p in 5 6 8; do
|
|
compctl -g "*.${p}" ${p}l
|
|
compctl -g "*.go" ${p}g
|
|
done
|
|
unset p
|
|
|
|
## aliases
|
|
alias gob='go build'
|
|
alias goc='go clean'
|
|
alias god='go doc'
|
|
alias goe='go env'
|
|
alias gof='go fmt'
|
|
alias gofa='go fmt ./...'
|
|
alias gofx='go fix'
|
|
alias gog='go get'
|
|
alias goga='go get ./...'
|
|
alias goi='go install'
|
|
alias gol='go list'
|
|
alias gom='go mod'
|
|
alias gomt='go mod tidy'
|
|
alias gopa='cd $GOPATH'
|
|
alias gopb='cd $GOPATH/bin'
|
|
alias gops='cd $GOPATH/src'
|
|
alias gor='go run'
|
|
alias got='go test'
|
|
alias gota='go test ./...'
|
|
alias goto='go tool'
|
|
alias gotoc='go tool compile'
|
|
alias gotod='go tool dist'
|
|
alias gotofx='go tool fix'
|
|
alias gov='go vet'
|
|
alias gove='go version'
|
|
alias gow='go work'
|
|
|
|
## prompt
|
|
function go_prompt_info() {
|
|
(( $+commands[go] )) || return
|
|
local go_prompt
|
|
go_prompt=$(go version | awk '{ print substr($3, 3) }')
|
|
[[ -z "${go_prompt}" ]] && return
|
|
echo "${ZSH_THEME_GO_PROMPT_PREFIX}${go_prompt:gs/%/%%}${ZSH_THEME_GO_PROMPT_SUFFIX}"
|
|
}
|