mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
Merge branch 'master' of https://github.com/ohmyzsh/ohmyzsh
This commit is contained in:
commit
5c0c4f093b
9 changed files with 75 additions and 174 deletions
|
|
@ -25,10 +25,7 @@ alias pacown='pacman -Qo'
|
||||||
alias pacupd="sudo pacman -Sy"
|
alias pacupd="sudo pacman -Sy"
|
||||||
|
|
||||||
function paclist() {
|
function paclist() {
|
||||||
local pkgs=$(LC_ALL=C pacman -Qqe)
|
pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
|
||||||
for pkg in ${(f)pkgs}; do
|
|
||||||
pacman -Qs --color=auto "^${pkg}\$" || break
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function pacdisowned() {
|
function pacdisowned() {
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ fi
|
||||||
|
|
||||||
{
|
{
|
||||||
# `docker completion` is only available from 23.0.0 on
|
# `docker completion` is only available from 23.0.0 on
|
||||||
local _docker_version=$(docker version --format '{{.Client.Version}}' 2>/dev/null)
|
local _docker_version=$(command docker version --format '{{.Client.Version}}' 2>/dev/null)
|
||||||
if is-at-least 23.0.0 $_docker_version; then
|
if is-at-least 23.0.0 $_docker_version; then
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `docker`. Otherwise, compinit will have already done that.
|
# bind it to `docker`. Otherwise, compinit will have already done that.
|
||||||
|
|
@ -47,6 +47,6 @@ fi
|
||||||
autoload -Uz _docker
|
autoload -Uz _docker
|
||||||
_comps[docker]=_docker
|
_comps[docker]=_docker
|
||||||
fi
|
fi
|
||||||
docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
|
command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
|
||||||
fi
|
fi
|
||||||
} &|
|
} &|
|
||||||
|
|
|
||||||
|
|
@ -80,22 +80,10 @@ __gitex_specific_branch_names() {
|
||||||
_wanted branch-names expl branch-name compadd - $branch_names
|
_wanted branch-names expl branch-name compadd - $branch_names
|
||||||
}
|
}
|
||||||
|
|
||||||
__gitex_chore_branch_names() {
|
|
||||||
__gitex_specific_branch_names 'chore'
|
|
||||||
}
|
|
||||||
|
|
||||||
__gitex_feature_branch_names() {
|
__gitex_feature_branch_names() {
|
||||||
__gitex_specific_branch_names 'feature'
|
__gitex_specific_branch_names 'feature'
|
||||||
}
|
}
|
||||||
|
|
||||||
__gitex_refactor_branch_names() {
|
|
||||||
__gitex_specific_branch_names 'refactor'
|
|
||||||
}
|
|
||||||
|
|
||||||
__gitex_bug_branch_names() {
|
|
||||||
__gitex_specific_branch_names 'bug'
|
|
||||||
}
|
|
||||||
|
|
||||||
__gitex_submodule_names() {
|
__gitex_submodule_names() {
|
||||||
local expl
|
local expl
|
||||||
declare -a submodule_names
|
declare -a submodule_names
|
||||||
|
|
@ -114,88 +102,29 @@ __gitex_author_names() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# subcommands
|
# subcommands
|
||||||
|
# new subcommand should be added in alphabetical order
|
||||||
_git-authors() {
|
_git-authors() {
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
'(--list -l)'{--list,-l}'[show authors]' \
|
'(--list -l)'{--list,-l}'[show authors]' \
|
||||||
'--no-email[without email]' \
|
'--no-email[without email]' \
|
||||||
}
|
}
|
||||||
|
|
||||||
_git-bug() {
|
|
||||||
local curcontext=$curcontext state line ret=1
|
|
||||||
declare -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
|
||||||
': :->command' \
|
|
||||||
'*:: :->option-or-argument' && ret=0
|
|
||||||
|
|
||||||
case $state in
|
|
||||||
(command)
|
|
||||||
declare -a commands
|
|
||||||
commands=(
|
|
||||||
'finish:merge bug into the current branch'
|
|
||||||
)
|
|
||||||
_describe -t commands command commands && ret=0
|
|
||||||
;;
|
|
||||||
(option-or-argument)
|
|
||||||
curcontext=${curcontext%:*}-$line[1]:
|
|
||||||
case $line[1] in
|
|
||||||
(finish)
|
|
||||||
_arguments -C \
|
|
||||||
':branch-name:__gitex_bug_branch_names'
|
|
||||||
;;
|
|
||||||
-r|--remote )
|
|
||||||
_arguments -C \
|
|
||||||
':remote-name:__gitex_remote_names'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
esac
|
|
||||||
|
|
||||||
_arguments \
|
|
||||||
'(--remote -r)'{--remote,-r}'[setup remote tracking branch]'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_git-changelog() {
|
_git-changelog() {
|
||||||
_arguments \
|
_arguments \
|
||||||
'(-l --list)'{-l,--list}'[list commits]' \
|
'(-l --list)'{-l,--list}'[list commits]' \
|
||||||
}
|
}
|
||||||
|
|
||||||
_git-chore() {
|
_git-clear() {
|
||||||
local curcontext=$curcontext state line ret=1
|
|
||||||
declare -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
|
||||||
': :->command' \
|
|
||||||
'*:: :->option-or-argument' && ret=0
|
|
||||||
|
|
||||||
case $state in
|
|
||||||
(command)
|
|
||||||
declare -a commands
|
|
||||||
commands=(
|
|
||||||
'finish:merge and delete the chore branch'
|
|
||||||
)
|
|
||||||
_describe -t commands command commands && ret=0
|
|
||||||
;;
|
|
||||||
(option-or-argument)
|
|
||||||
curcontext=${curcontext%:*}-$line[1]:
|
|
||||||
case $line[1] in
|
|
||||||
(finish)
|
|
||||||
_arguments -C \
|
|
||||||
':branch-name:__gitex_chore_branch_names'
|
|
||||||
;;
|
|
||||||
-r|--remote )
|
|
||||||
_arguments -C \
|
|
||||||
':remote-name:__gitex_remote_names'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
esac
|
|
||||||
|
|
||||||
_arguments \
|
_arguments \
|
||||||
'(--remote -r)'{--remote,-r}'[setup remote tracking branch]'
|
'(-f --force)'{-f,--force}'[force clear]' \
|
||||||
|
'(-h --help)'{-h,--help}'[help message]' \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_git-coauthor() {
|
||||||
|
_arguments \
|
||||||
|
':co-author[co-author to add]' \
|
||||||
|
':co-author-email[email address of co-author to add]'
|
||||||
|
}
|
||||||
|
|
||||||
_git-contrib() {
|
_git-contrib() {
|
||||||
_arguments \
|
_arguments \
|
||||||
|
|
@ -235,6 +164,11 @@ _git-delete-branch() {
|
||||||
':branch-name:__gitex_branch_names'
|
':branch-name:__gitex_branch_names'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_git-delete-squashed-branches() {
|
||||||
|
_arguments \
|
||||||
|
':branch-name:__gitex_branch_names'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_git-delete-submodule() {
|
_git-delete-submodule() {
|
||||||
_arguments \
|
_arguments \
|
||||||
|
|
@ -298,6 +232,7 @@ _git-feature() {
|
||||||
case $line[1] in
|
case $line[1] in
|
||||||
(finish)
|
(finish)
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
|
'--squash[Use squash merge]' \
|
||||||
':branch-name:__gitex_feature_branch_names'
|
':branch-name:__gitex_feature_branch_names'
|
||||||
;;
|
;;
|
||||||
-r|--remote )
|
-r|--remote )
|
||||||
|
|
@ -327,20 +262,17 @@ _git-guilt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_git-ignore() {
|
_git-ignore() {
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
'(--local -l)'{--local,-l}'[show local gitignore]' \
|
'(--local -l)'{--local,-l}'[show local gitignore]' \
|
||||||
'(--global -g)'{--global,-g}'[show global gitignore]' \
|
'(--global -g)'{--global,-g}'[show global gitignore]' \
|
||||||
'(--private -p)'{--private,-p}'[show repo gitignore]'
|
'(--private -p)'{--private,-p}'[show repo gitignore]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_git-ignore() {
|
_git-info() {
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
'(--append -a)'{--append,-a}'[append .gitignore]' \
|
'(--color -c)'{--color,-c}'[use color for information titles]' \
|
||||||
'(--replace -r)'{--replace,-r}'[replace .gitignore]' \
|
'--no-config[do not show list all variables set in config file, along with their values]'
|
||||||
'(--list-in-table -l)'{--list-in-table,-l}'[print available types in table format]' \
|
|
||||||
'(--list-alphabetically -L)'{--list-alphabetically,-L}'[print available types in alphabetical order]' \
|
|
||||||
'(--search -s)'{--search,-s}'[search word in available types]'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -357,50 +289,27 @@ _git-missing() {
|
||||||
':second-branch-name:__gitex_branch_names'
|
':second-branch-name:__gitex_branch_names'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_git-release() {
|
||||||
_git-refactor() {
|
|
||||||
local curcontext=$curcontext state line ret=1
|
|
||||||
declare -A opt_args
|
|
||||||
|
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
': :->command' \
|
'-c[Generates/populates the changelog with all commit message since the last tag.]' \
|
||||||
'*:: :->option-or-argument' && ret=0
|
'-r[The "remote" repository that is destination of a push operation.]' \
|
||||||
|
'-m[use the custom commit information instead of the default message.]' \
|
||||||
case $state in
|
'-s[Create a signed and annotated tag.]' \
|
||||||
(command)
|
'-u[Create a tag, annotated and signed with the given key.]' \
|
||||||
declare -a commands
|
'--semver[If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag.]' \
|
||||||
commands=(
|
'--prefix[Add a prefix string to semver to allow more complex tags.]' \
|
||||||
'finish:merge refactor into the current branch'
|
'--no-empty-commit[Avoid creating empty commit if nothing could be committed.]' \
|
||||||
)
|
'--[The arguments listed after "--" separator will be passed to pre/post-release hook.]'
|
||||||
_describe -t commands command commands && ret=0
|
|
||||||
;;
|
|
||||||
(option-or-argument)
|
|
||||||
curcontext=${curcontext%:*}-$line[1]:
|
|
||||||
case $line[1] in
|
|
||||||
(finish)
|
|
||||||
_arguments -C \
|
|
||||||
':branch-name:__gitex_refactor_branch_names'
|
|
||||||
;;
|
|
||||||
-r|--remote )
|
|
||||||
_arguments -C \
|
|
||||||
':remote-name:__gitex_remote_names'
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
return 0
|
|
||||||
esac
|
|
||||||
|
|
||||||
_arguments \
|
|
||||||
'(--remote -r)'{--remote,-r}'[setup remote tracking branch]'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_git-squash() {
|
_git-squash() {
|
||||||
|
_arguments '--squash-msg[commit with the squashed commit messages]'
|
||||||
_arguments \
|
_arguments \
|
||||||
':branch-name:__gitex_branch_names'
|
':branch-name:__gitex_branch_names'
|
||||||
}
|
}
|
||||||
|
|
||||||
_git-stamp() {
|
_git-stamp() {
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
'(--replace -r)'{--replace,-r}'[replace stamps with same id]'
|
'(--replace -r)'{--replace,-r}'[replace stamps with same id]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -413,17 +322,19 @@ _git-standup() {
|
||||||
'-g[Display GPG signed info]' \
|
'-g[Display GPG signed info]' \
|
||||||
'-h[Display help message]' \
|
'-h[Display help message]' \
|
||||||
'-L[Enable the inclusion of symbolic links]' \
|
'-L[Enable the inclusion of symbolic links]' \
|
||||||
'-m[The depth of recursive directory search]'
|
'-m[The depth of recursive directory search]' \
|
||||||
|
'-B[Display the commits in branch groups]'
|
||||||
}
|
}
|
||||||
|
|
||||||
_git-summary() {
|
_git-summary() {
|
||||||
_arguments '--line[summarize with lines rather than commits]'
|
_arguments '--line[summarize with lines rather than commits]'
|
||||||
|
_arguments '--dedup-by-email[remove duplicate users by the email address]'
|
||||||
|
_arguments '--no-merges[exclude merge commits]'
|
||||||
__gitex_commits
|
__gitex_commits
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_git-undo(){
|
_git-undo(){
|
||||||
_arguments -C \
|
_arguments -C \
|
||||||
'(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
|
'(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
|
||||||
'(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
|
'(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
|
||||||
}
|
}
|
||||||
|
|
@ -432,21 +343,26 @@ zstyle -g existing_user_commands ':completion:*:*:git:*' user-commands
|
||||||
|
|
||||||
zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
|
zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
|
||||||
alias:'define, search and show aliases' \
|
alias:'define, search and show aliases' \
|
||||||
|
abort:'abort current revert, merge, rebase, or cherry-pick process' \
|
||||||
archive-file:'export the current head of the git repository to an archive' \
|
archive-file:'export the current head of the git repository to an archive' \
|
||||||
authors:'generate authors report' \
|
authors:'generate authors report' \
|
||||||
back:'undo and stage latest commits' \
|
browse:'open repo website in browser' \
|
||||||
|
browse-ci:'open repo CI page in browser' \
|
||||||
bug:'create bug branch' \
|
bug:'create bug branch' \
|
||||||
bulk:'run bulk commands' \
|
bulk:'run bulk commands' \
|
||||||
|
brv:'list branches sorted by their last commit date'\
|
||||||
changelog:'generate a changelog report' \
|
changelog:'generate a changelog report' \
|
||||||
chore:'create chore branch' \
|
chore:'create chore branch' \
|
||||||
clear-soft:'soft clean up a repository' \
|
clear-soft:'soft clean up a repository' \
|
||||||
clear:'rigorously clean up a repository' \
|
clear:'rigorously clean up a repository' \
|
||||||
|
coauthor:'add a co-author to the last commit' \
|
||||||
commits-since:'show commit logs since some date' \
|
commits-since:'show commit logs since some date' \
|
||||||
contrib:'show user contributions' \
|
contrib:'show user contributions' \
|
||||||
count:'show commit count' \
|
count:'show commit count' \
|
||||||
create-branch:'create branches' \
|
create-branch:'create branches' \
|
||||||
delete-branch:'delete branches' \
|
delete-branch:'delete branches' \
|
||||||
delete-merged-branches:'delete merged branches' \
|
delete-merged-branches:'delete merged branches' \
|
||||||
|
delete-squashed-branches:'delete squashed branches' \
|
||||||
delete-submodule:'delete submodules' \
|
delete-submodule:'delete submodules' \
|
||||||
delete-tag:'delete tags' \
|
delete-tag:'delete tags' \
|
||||||
delta:'lists changed files' \
|
delta:'lists changed files' \
|
||||||
|
|
@ -465,11 +381,13 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
|
||||||
local-commits:'list local commits' \
|
local-commits:'list local commits' \
|
||||||
lock:'lock a file excluded from version control' \
|
lock:'lock a file excluded from version control' \
|
||||||
locked:'ls files that have been locked' \
|
locked:'ls files that have been locked' \
|
||||||
|
magic:'commits everything with a generated message' \
|
||||||
merge-into:'merge one branch into another' \
|
merge-into:'merge one branch into another' \
|
||||||
merge-repo:'merge two repo histories' \
|
merge-repo:'merge two repo histories' \
|
||||||
missing:'show commits missing from another branch' \
|
missing:'show commits missing from another branch' \
|
||||||
mr:'checks out a merge request locally' \
|
mr:'checks out a merge request locally' \
|
||||||
obliterate:'rewrite past commits to remove some files' \
|
obliterate:'rewrite past commits to remove some files' \
|
||||||
|
paste:'send patches to pastebin sites' \
|
||||||
pr:'checks out a pull request locally' \
|
pr:'checks out a pull request locally' \
|
||||||
psykorebase:'rebase a branch with a merge commit' \
|
psykorebase:'rebase a branch with a merge commit' \
|
||||||
pull-request:'create pull request to GitHub project' \
|
pull-request:'create pull request to GitHub project' \
|
||||||
|
|
@ -479,6 +397,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
|
||||||
release:'commit, tag and push changes to the repository' \
|
release:'commit, tag and push changes to the repository' \
|
||||||
rename-branch:'rename a branch' \
|
rename-branch:'rename a branch' \
|
||||||
rename-tag:'rename a tag' \
|
rename-tag:'rename a tag' \
|
||||||
|
rename-remote:'rename a remote' \
|
||||||
repl:'git read-eval-print-loop' \
|
repl:'git read-eval-print-loop' \
|
||||||
reset-file:'reset one file' \
|
reset-file:'reset one file' \
|
||||||
root:'show path of root' \
|
root:'show path of root' \
|
||||||
|
|
@ -495,4 +414,5 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
|
||||||
sync:'sync local branch with remote branch' \
|
sync:'sync local branch with remote branch' \
|
||||||
touch:'touch and add file to the index' \
|
touch:'touch and add file to the index' \
|
||||||
undo:'remove latest commits' \
|
undo:'remove latest commits' \
|
||||||
unlock:'unlock a file excluded from version control'
|
unlock:'unlock a file excluded from version control' \
|
||||||
|
utimes:'change files modification time to their last commit date'
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,7 @@ These features allow to pause a branch development and switch to another one (_"
|
||||||
| work_in_progress | Echoes a warning if the current branch is a wip |
|
| work_in_progress | Echoes a warning if the current branch is a wip |
|
||||||
| gwip | Commit wip branch |
|
| gwip | Commit wip branch |
|
||||||
| gunwip | Uncommit wip branch |
|
| gunwip | Uncommit wip branch |
|
||||||
| gunwipall | Uncommit `--wip--` commits recursively |
|
| gunwipall | Uncommit all recent `--wip--` commits |
|
||||||
|
|
||||||
### Deprecated functions
|
### Deprecated functions
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,18 +27,14 @@ function work_in_progress() {
|
||||||
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
|
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Same as `gunwip` but recursive
|
# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one
|
||||||
# "Unwips" all recent `--wip--` commits in loop until there is no left
|
|
||||||
function gunwipall() {
|
function gunwipall() {
|
||||||
while true; do
|
local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H)
|
||||||
commit_message=$(git rev-list --max-count=1 --format="%s" HEAD)
|
|
||||||
if [[ $commit_message =~ "--wip--" ]]; then
|
# Check if a commit without "--wip--" was found and it's not the same as HEAD
|
||||||
git reset "HEAD~1"
|
if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then
|
||||||
(( $? )) && return 1
|
git reset $_commit || return 1
|
||||||
else
|
fi
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if main exists and use instead of master
|
# Check if main exists and use instead of master
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ if it's found, or the mvn command otherwise.
|
||||||
| `mvnct` | `mvn clean test` |
|
| `mvnct` | `mvn clean test` |
|
||||||
| `mvncv` | `mvn clean verify` |
|
| `mvncv` | `mvn clean verify` |
|
||||||
| `mvncvst` | `mvn clean verify -DskipTests` |
|
| `mvncvst` | `mvn clean verify -DskipTests` |
|
||||||
| `mvnd` | `mvn deploy` |
|
| `mvndp` | `mvn deploy` |
|
||||||
| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
|
| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
|
||||||
| `mvndt` | `mvn dependency:tree` |
|
| `mvndt` | `mvn dependency:tree` |
|
||||||
| `mvne` | `mvn eclipse:eclipse` |
|
| `mvne` | `mvn eclipse:eclipse` |
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ alias mvncp='mvn clean package'
|
||||||
alias mvnct='mvn clean test'
|
alias mvnct='mvn clean test'
|
||||||
alias mvncv='mvn clean verify'
|
alias mvncv='mvn clean verify'
|
||||||
alias mvncvst='mvn clean verify -DskipTests'
|
alias mvncvst='mvn clean verify -DskipTests'
|
||||||
alias mvnd='mvn deploy'
|
alias mvndp='mvn deploy'
|
||||||
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
|
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
|
||||||
alias mvndt='mvn dependency:tree'
|
alias mvndt='mvn dependency:tree'
|
||||||
alias mvne='mvn eclipse:eclipse'
|
alias mvne='mvn eclipse:eclipse'
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ...
|
||||||
|
|
||||||
#### `.nvmrc` autoload
|
#### `.nvmrc` autoload
|
||||||
|
|
||||||
|
Note: _this option cannot be used at the same time as `lazy`. `autoload` will override it and load `nvm` at
|
||||||
|
startup._
|
||||||
|
|
||||||
If set, the plugin will automatically load a node version when if finds a
|
If set, the plugin will automatically load a node version when if finds a
|
||||||
[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node
|
[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node
|
||||||
version to load. This can be done, similar as previous options, adding:
|
version to load. This can be done, similar as previous options, adding:
|
||||||
|
|
|
||||||
|
|
@ -16,30 +16,18 @@ fi
|
||||||
# Note: nvm is a function so we need to use `which`
|
# Note: nvm is a function so we need to use `which`
|
||||||
which nvm &>/dev/null && return
|
which nvm &>/dev/null && return
|
||||||
|
|
||||||
# TODO: 2022-11-11: Remove soft-deprecate options
|
if [[ -z "$NVM_DIR" ]]; then
|
||||||
if (( ${+NVM_LAZY} + ${+NVM_LAZY_CMD} + ${+NVM_AUTOLOAD} )); then
|
echo "[oh-my-zsh] nvm installation cannot be found"
|
||||||
# Get list of NVM_* variable settings defined
|
echo "[oh-my-zsh] set NVM_DIR to your installation"
|
||||||
local -a used_vars
|
return
|
||||||
used_vars=(${(o)parameters[(I)NVM_(AUTOLOAD|LAZY|LAZY_CMD)]})
|
fi
|
||||||
# Nicely print the list in the style `var1, var2 and var3`
|
if [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
|
||||||
echo "${fg[yellow]}[nvm plugin] Variable-style settings are deprecated. Instead of ${(j:, :)used_vars[1,-2]}${used_vars[-2]+ and }${used_vars[-1]}, use:\n"
|
echo "[oh-my-zsh] nvm.sh does not exist in $NVM_DIR"
|
||||||
if (( $+NVM_AUTOLOAD )); then
|
return
|
||||||
echo " zstyle ':omz:plugins:nvm' autoload yes"
|
|
||||||
zstyle ':omz:plugins:nvm' autoload yes
|
|
||||||
fi
|
|
||||||
if (( $+NVM_LAZY )); then
|
|
||||||
echo " zstyle ':omz:plugins:nvm' lazy yes"
|
|
||||||
zstyle ':omz:plugins:nvm' lazy yes
|
|
||||||
fi
|
|
||||||
if (( $+NVM_LAZY_CMD )); then
|
|
||||||
echo " zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD"
|
|
||||||
zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD
|
|
||||||
fi
|
|
||||||
echo "$reset_color"
|
|
||||||
unset used_vars NVM_AUTOLOAD NVM_LAZY NVM_LAZY_CMD
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if zstyle -t ':omz:plugins:nvm' lazy; then
|
if zstyle -t ':omz:plugins:nvm' lazy && \
|
||||||
|
! zstyle -t ':omz:plugins:nvm' autoload; then
|
||||||
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
|
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
|
||||||
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
|
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
|
||||||
eval "
|
eval "
|
||||||
|
|
@ -51,11 +39,8 @@ if zstyle -t ':omz:plugins:nvm' lazy; then
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
unset nvm_lazy_cmd
|
unset nvm_lazy_cmd
|
||||||
elif [[ -f "$NVM_DIR/nvm.sh" ]]; then
|
|
||||||
# Load nvm if it exists in $NVM_DIR
|
|
||||||
source "$NVM_DIR/nvm.sh"
|
|
||||||
else
|
else
|
||||||
return
|
source "$NVM_DIR/nvm.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Autoload nvm when finding a .nvmrc file in the current directory
|
# Autoload nvm when finding a .nvmrc file in the current directory
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue