mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-21 18:46:06 +02:00
Compare commits
4
Commits
6cd3a0baf6
...
0ee67f0428
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ee67f0428 | ||
|
|
ec2901b7d0 | ||
|
|
1396cdd674 | ||
|
|
2ea948e05b |
@@ -738,6 +738,9 @@ function _omz::reload {
|
|||||||
|
|
||||||
# Old zsh versions don't have ZSH_ARGZERO
|
# Old zsh versions don't have ZSH_ARGZERO
|
||||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||||
|
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
||||||
|
# anything that is not absolute (see #13919)
|
||||||
|
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="$commands[zsh]"
|
||||||
# Check whether to run a login shell
|
# Check whether to run a login shell
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||||
}
|
}
|
||||||
@@ -919,6 +922,9 @@ function _omz::update {
|
|||||||
if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
if [[ "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||||
# Old zsh versions don't have ZSH_ARGZERO
|
# Old zsh versions don't have ZSH_ARGZERO
|
||||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||||
|
# ZSH_ARGZERO is how zsh was invoked, not the path to it, so re-resolve
|
||||||
|
# anything that is not absolute (see #13919)
|
||||||
|
[[ "${zsh#-}" != /* ]] && (( $+commands[zsh] )) && zsh="$commands[zsh]"
|
||||||
# Check whether to run a login shell
|
# Check whether to run a login shell
|
||||||
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ receive further support.
|
|||||||
| `git_current_user_name` | Returns the `user.name` config value (Lives in `lib/git.zsh`) |
|
| `git_current_user_name` | Returns the `user.name` config value (Lives in `lib/git.zsh`) |
|
||||||
| `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
|
| `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
|
||||||
| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise |
|
| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise |
|
||||||
|
| `gbcopy` | Copies current branch name to clipboard |
|
||||||
| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote |
|
| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote |
|
||||||
| `gbda` | Deletes all merged branches |
|
| `gbda` | Deletes all merged branches |
|
||||||
| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |
|
| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |
|
||||||
|
|||||||
@@ -49,6 +49,16 @@ function git_main_branch() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gbcopy() {
|
||||||
|
command git rev-parse --git-dir &>/dev/null || return
|
||||||
|
|
||||||
|
local branch
|
||||||
|
branch="$(git_current_branch)" || return
|
||||||
|
[[ -n "$branch" ]] || return 1
|
||||||
|
|
||||||
|
print -rn -- "$branch" | clipcopy
|
||||||
|
}
|
||||||
|
|
||||||
function grename() {
|
function grename() {
|
||||||
if [[ -z "$1" || -z "$2" ]]; then
|
if [[ -z "$1" || -z "$2" ]]; then
|
||||||
echo "Usage: $0 old_branch new_branch"
|
echo "Usage: $0 old_branch new_branch"
|
||||||
|
|||||||
+95
-11
@@ -81,6 +81,7 @@ _go() {
|
|||||||
'tool[run specified go tool]'
|
'tool[run specified go tool]'
|
||||||
'version[print Go version]'
|
'version[print Go version]'
|
||||||
'vet[run go tool vet on packages]'
|
'vet[run go tool vet on packages]'
|
||||||
|
'work[workspace maintenance]'
|
||||||
)
|
)
|
||||||
if (( CURRENT == 2 )); then
|
if (( CURRENT == 2 )); then
|
||||||
# explain go commands
|
# explain go commands
|
||||||
@@ -88,19 +89,38 @@ _go() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
build_flags=(
|
build_flags=(
|
||||||
'-a[force reinstallation of packages that are already up to date]'
|
'-C[change to dir before running the command]:directory:_path_files -/'
|
||||||
|
'-a[force rebuilding of packages that are already up-to-date]'
|
||||||
'-n[print the commands but do not run them]'
|
'-n[print the commands but do not run them]'
|
||||||
'-p[number of parallel builds]:number'
|
'-p[number of parallel builds]:number'
|
||||||
'-race[enable data race detection]'
|
'-race[enable data race detection]'
|
||||||
'-x[print the commands]'
|
'-msan[enable interoperation with memory sanitizer]'
|
||||||
|
'-asan[enable interoperation with address sanitizer]'
|
||||||
|
'-cover[enable code coverage instrumentation]'
|
||||||
|
'-covermode[set the mode for coverage analysis]:mode:(set count atomic)'
|
||||||
|
'-coverpkg[apply coverage analysis to matching packages]:pattern'
|
||||||
|
'-v[print the names of packages as they are compiled]'
|
||||||
'-work[print temporary directory name and keep it]'
|
'-work[print temporary directory name and keep it]'
|
||||||
'-ccflags[flags for 5c/6c/8c]:flags'
|
'-x[print the commands]'
|
||||||
'-gcflags[flags for 5g/6g/8g]:flags'
|
'-asmflags[arguments to pass on each go tool asm invocation]:flags'
|
||||||
'-ldflags[flags for 5l/6l/8l]:flags'
|
'-buildmode[build mode to use]:mode:(archive c-archive c-shared default shared exe pie plugin)'
|
||||||
'-gccgoflags[flags for gccgo]:flags'
|
'-buildvcs[stamp binaries with version control information]:mode:(true false auto)'
|
||||||
'-compiler[name of compiler to use]:name'
|
'-compiler[name of compiler to use]:name:(gccgo gc)'
|
||||||
'-installsuffix[suffix to add to package directory]:suffix'
|
'-gccgoflags[arguments to pass on each gccgo compiler/linker invocation]:flags'
|
||||||
|
'-gcflags[arguments to pass on each go tool compile invocation]:flags'
|
||||||
|
'-installsuffix[suffix to use in the package installation directory]:suffix'
|
||||||
|
'-json[emit build output in JSON suitable for automated processing]'
|
||||||
|
'-ldflags[arguments to pass on each go tool link invocation]:flags'
|
||||||
|
'-linkshared[build code that will be linked against shared libraries]'
|
||||||
|
'-mod[module download mode to use]:mode:(readonly vendor mod)'
|
||||||
|
'-modcacherw[leave newly-created directories in the module cache read-write]'
|
||||||
|
'-modfile[read and write an alternate go.mod file]:file:_files -g "*.mod"'
|
||||||
|
'-overlay[read a JSON config file that provides an overlay for build operations]:file:_files -g "*.json"'
|
||||||
|
'-pgo[specify the file path of a profile for profile-guided optimization]:file:_files'
|
||||||
|
'-pkgdir[install and load all packages from dir]:directory:_path_files -/'
|
||||||
'-tags[list of build tags to consider satisfied]:tags'
|
'-tags[list of build tags to consider satisfied]:tags'
|
||||||
|
'-trimpath[remove all file system paths from the resulting executable]'
|
||||||
|
'-toolexec[program to use to invoke toolchain programs]:command'
|
||||||
)
|
)
|
||||||
|
|
||||||
case ${words[2]} in
|
case ${words[2]} in
|
||||||
@@ -125,17 +145,20 @@ _go() {
|
|||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
_arguments -s -w : ${build_flags[@]} \
|
_arguments -s -w : ${build_flags[@]} \
|
||||||
"-v[show package names]" \
|
|
||||||
'*:importpaths:__go_packages'
|
'*:importpaths:__go_packages'
|
||||||
;;
|
;;
|
||||||
get)
|
get)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]}
|
${build_flags[@]} \
|
||||||
|
"-t[consider modules needed to build tests of packages]" \
|
||||||
|
"-u[update modules providing dependencies to newer minor or patch releases]" \
|
||||||
|
"-u=[update modules providing dependencies to patch releases]:mode:(patch)" \
|
||||||
|
"-tool[add a matching tool line to go.mod for each listed package]" \
|
||||||
|
"*:importpaths:__go_packages"
|
||||||
;;
|
;;
|
||||||
build)
|
build)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
"-v[show package names]" \
|
|
||||||
"-o[output file]:file:_files" \
|
"-o[output file]:file:_files" \
|
||||||
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
|
||||||
;;
|
;;
|
||||||
@@ -238,6 +261,60 @@ _go() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
work)
|
||||||
|
local -a work_commands
|
||||||
|
work_commands+=(
|
||||||
|
'edit[edit go.work from tools or scripts]'
|
||||||
|
'init[initialize workspace file]'
|
||||||
|
'sync[sync workspace build list to modules]'
|
||||||
|
'use[add modules to workspace file]'
|
||||||
|
'vendor[make vendored copy of dependencies]'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (( CURRENT == 3 )); then
|
||||||
|
_values 'go work commands' ${work_commands[@]} "help[display help]"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${words[3]} in
|
||||||
|
help)
|
||||||
|
_values 'go work commands' ${work_commands[@]}
|
||||||
|
;;
|
||||||
|
edit)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-fmt[reformat the go.work file]" \
|
||||||
|
"-godebug[=key=value add a godebug key=value line]:key=value" \
|
||||||
|
"-dropgodebug[=key drop an existing godebug line]:key" \
|
||||||
|
"-use[=path add a use directive]:directory:_path_files -/" \
|
||||||
|
"-dropuse[=path drop a use directive]:directory:_path_files -/" \
|
||||||
|
"-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \
|
||||||
|
"-dropreplace[=old{@v} drop a replacement of the given module path and version pair]:name" \
|
||||||
|
"-go[={version} set the expected Go language version]:number" \
|
||||||
|
"-toolchain[=name set the Go toolchain to use]:name" \
|
||||||
|
"-print[print the final go.work in its text format]" \
|
||||||
|
"-json[print the final go.work file in JSON format]" \
|
||||||
|
"1:go.work file:_files -g 'go.work'"
|
||||||
|
;;
|
||||||
|
init)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"*:module directories:_path_files -/"
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
;;
|
||||||
|
use)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-r[search recursively for modules in the argument directories]" \
|
||||||
|
"*:module directories:_path_files -/"
|
||||||
|
;;
|
||||||
|
vendor)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-e[attempt to proceed despite errors encountered while loading packages]" \
|
||||||
|
"-v[print the names of vendored modules and packages]" \
|
||||||
|
"-o[create the vendor directory at the given path]:output directory:_path_files -/" \
|
||||||
|
"*:flags"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
help)
|
help)
|
||||||
_values "${commands[@]}" \
|
_values "${commands[@]}" \
|
||||||
'environment[show Go environment variables available]' \
|
'environment[show Go environment variables available]' \
|
||||||
@@ -247,6 +324,13 @@ _go() {
|
|||||||
'testflag[description of testing flags]' \
|
'testflag[description of testing flags]' \
|
||||||
'testfunc[description of testing functions]'
|
'testfunc[description of testing functions]'
|
||||||
;;
|
;;
|
||||||
|
version)
|
||||||
|
_arguments -s -w : \
|
||||||
|
"-m[print module version information]" \
|
||||||
|
"-v[report unrecognized files]" \
|
||||||
|
"-json[print module version information in JSON format]" \
|
||||||
|
"*:file:_files"
|
||||||
|
;;
|
||||||
run)
|
run)
|
||||||
_arguments -s -w : \
|
_arguments -s -w : \
|
||||||
${build_flags[@]} \
|
${build_flags[@]} \
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
PROMPT="${FG[117]}%~%{$reset_color%}\$(git_prompt_info)\$(virtualenv_prompt_info)${FG[133]}\$(git_prompt_status) ${FG[077]}ᐅ%{$reset_color%} "
|
PROMPT="${FG[117]}%~%{$reset_color%}\$(git_prompt_info)\$(virtualenv_prompt_info)${FG[133]}\$(git_prompt_status) ${FG[077]}%(?..${FG[160]}[%?] )ᐅ%{$reset_color%} "
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[012]}("
|
ZSH_THEME_GIT_PROMPT_PREFIX=" ${FG[012]}("
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[012]})%{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="${FG[012]})%{$reset_color%}"
|
||||||
|
|||||||
Reference in New Issue
Block a user