I've recently switched over to zshrc and every time I load up my terminal, I get this error message:
Last login: Tue Nov 26 12:20:36 on ttys000
complete:13: command not found: compdef
complete:13: command not found: compdef
I looked for other answers/solutions and some posts have hinted at something in the .zshrc file; mine looks like this:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Just in case, I also checked my .zprofile file, but it only has this line in it:
source ~/.zshrc
One of the posts that I came across hinted that the problem was in the export NVM section of the .zshrc file, however, I'm not sure how to resolve this. There was one solution that referenced the placement/order of the export NVM.. block in the .zshrc file; am i missing something or have I misplaced/incorrectly ordered something in my .zshrc file?
I'm not sure what is calling complete, but compdef is defined by compinit, so you need to call that first.
autoload -Uz compinit
compinit
# Now you can write code that calls compdef
If you run compinstall, it will add the necessary lines to your .zshrc for you.
Related
I modified /etc/bash_completion (which is just wrapper for /usr/share/bash-completion/bash_completion, and this will load individual scripts within /usr/share/bash-completion/completions/*) (due to that latest bash-completion's apt-get and apt-fast completion do not hold autopurge definition) but it seems my zsh (oh-my-zsh) shell never load the new definition anyway.
I tried the method which enters bash first, sources /etc/bash_completion, then enters zsh again but it seems entering zsh again overwrites the loaded completions again (it works with bash).
I tried majority of online solutions about bash-completion plus zsh issue, including defining autoload -U +X compinit && compinit and autoload -U +X bashcompinit && bashcompinit at the head of ~/.zshrc, using gitfast (which is included in oh-my-zsh by default) that seems to (try to) load system bash-completion file, and zsh-bash-completions-fallback but no luck.
Directly sourcing /etc/bash_completion does not work as it cannot handle shopt builtin for bash only, and zsh-completion seems to hold only partial definitions, excluding apt, apt-get, and apt-fast completions.
I post my ~/.zshrc here of which default comments are removed:
# Workaround: `bashcompinit` first, right after `compinit`
autoload -U +X compinit && compinit
autoload -U +X bashcompinit && bashcompinit
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="powerlevel10k/powerlevel10k"
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
gitfast
sudo
web-search
autojump
zsh-autosuggestions
zsh-syntax-highlighting
)
# `sudo -E` workaround
# You must place this before sourcing $ZSH/oh-my-zsh.sh.
ZSH_DISABLE_COMPFIX=true
source $ZSH/oh-my-zsh.sh
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Workaround: Append local alias with sudo
alias sudo="sudo "
# command-not-found
if [[ -s '/etc/zsh_command_not_found' ]]; then
source '/etc/zsh_command_not_found'
fi
# apt-fast
alias apt="apt-fast"
alias apt-get="apt-fast"
# zsh-autosuggestions
bindkey '^I' complete-word # tab => complete
bindkey '^[[Z' autosuggest-accept # shift + tab => autosuggest
P.S:
On my user account, ~/.bash* and ~/.profile do not exist since I remove them all.
I have recently just started using wsl and zsh for dev purposes and I have tried to add the nvm through as a plugin in zsh through the ~/.zshrc file. I've added, saved and reloaded the terminal several times and tries the nvm command and it comes out with the 'zsh: command not found: nvm' error.
Any suggestions?
You can add nvm's loading script to ~/.zshrc. This instruction can be found on the readme.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
You can test with:
which node
Hope this works :)
I want to execute command gclient. I have already included its location in PATH. But I cannot directly execute it by command. Can someone tell me why?
~
❯ echo $PATH
/User/merle/depot_tools:/Users/merle/.nvm/versions/node/v11.10.0/bin:/usr/local/opt/mysql#5.5/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
~
❯ ls depot_tools | grep gclient
README.gclient.md
annotated_gclient.py
gclient
gclient-new-workdir.py
gclient.bat
gclient.py
gclient_completion.sh
gclient_eval.py
gclient_paths.py
gclient_scm.py
gclient_utils.py
~
❯ gclient
zsh: command not found: gclient
~
❯ cd depot_tools
~/depot_tools master
❯ ./gclient
Usage: gclient.py <command> [options]
Meta checkout dependency manager for Git.
Commands are:.......
Take another look at your path:
export PATH=/User/merle/depot_tools:/Users/merle/...
Does your system contain just 1 User or multiple Users???
It should read:
export PATH=/Users/merle/depot_tools:/Users/merle/...
i think you may forget
source ~/.nvm/nvm.sh
if you want automatically load it ,there are two ways
open ~/.zshrc
1.add
source ~/.nvm/nvm.sh
2.or add
export NVM_DIR="/Users/YOUR_USER_NAME(you need use you user name)/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
hope this can help you
ZSH: command not found
The Problem was .zshrc, it was missing.
the solution which worked for me :
You have to create a .zshrc file.
to create use "vim .zshrc" command then insurt your path "export PATH="$PATH:pwd/flutter/bin"
save and completely exit your terminal completely. install gem cocoa pods then accept the license. you are good to go.
I'm using hyper terminal on Windows 10 with WSL(Windows Subsystem for Linux). I've got wsl to default to zsh but whenever I run npm or node i get the "zsh: command not found: node" or npm. To fix this i have to enter "bash" let the terminal switch to bash and then enter "zsh" to switch back. After that node and npm commands work.
Please help! I tried looking at existing posts but didn't find anything relating to this issue.
Thanks for your help in advance!
Just figured it out. Had to add the following in my .zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_comp$
Although this does make zsh take a long time to load initially.
os: macOS Sierra 10.12.6 (16G29)
terminal app: Hyper 1.3.3.1754
nvm: 0.33.2
I installed nvm, according to the instruction, sometime ago without issue. Recently, it and the commands it's responsible for —node and npm— stopped working.
nvm/npm/node command not found
I realized that this occurred because I recently switched my system default shell from bash to zsh —chsh -s /bin/zsh— without addressing the contents of ~/.bash_profile which is sourced by bash but not zsh.
The nvm install script
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
places the following in the appropriate config file —one of: ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
At time of install I used bash and that bit was placed in ~/.bash_profile. Coping that content over to ~/.zshrc got the commands working again.