Zsh Docker Plugin not Working - zsh

I have been using oh-my-zsh for a while now and the docker plugin as recently stopped working for me for some reason.
I checked my ~/.zshrc file and the plugin is included
plugins=(git colored-man colorize github jira vagrant virtualenv pip python brew osx zsh-syntax-highlighting docker)
I checked the ~/.oh-my-zsh/plugins/docker directory and there is a _docker file in there. Yet when I type docker and press Tab, I get none of the autocomplete shortcuts that I used to get.
I can confirm that my git plugin works just fine but not the docker plugin. Tried doing exec zsh and source ~/.zshrc and restarted my terminal but no luck.
Am I missing something?

You might want to try and remove any .zcompdump-(...) files you may have on your user's home directory - using something like rm ~/.zcompdump* on a terminal, or some file browser - and then reload the .zschrc file with the command source ~/.zshrc or restart the terminal - whichever works best for you. See this
Then see if it works.

It seems oh-my-zsh is not loading plugins/docker/_docker file. You must add it to ~/.zshrc in an another way.
Add these lines to your ~/.zshrc file:
fpath+=($ZSH/plugins/docker)
autoload -U compinit && compinit

For me it was simply the case that I needed to launch Docker for the first time from spotlight on my Mac in order for Docker for Desktop to get the access it needed. Then the docker version command worked just fine.

Follow these steps if you are using oh-my-zsh and autocomplete is not working:
Make the following three links:
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.zsh-completion /usr/local/share/zsh/site-functions/_docker-machine
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose
Either add autoload -Uz compinit; compinit to .zshrc or run in your shell:
echo "autoload -Uz compinit; compinit" >> .zshrc

In my case: Windows 10 + WSL2 + Hyper
I was having this error because I stopped Docker on Windows... Starting it again makes the error disappear in Hyper (thus, also in ZSH).
No .zshrc changes or additional commands to add inside.

#youhans's solution worked for me permanently. You might have permission issue to make needed adjustment on "zshrc". I have changed the permission to "read and write" and added the code snippet from #youhans's response to the end of "zshrc" file. Now completion system always works.
Before I had to type below snippet in command line whenever open a new terminal.
autoload -Uz compinit && compinit

In my case it occurred because of an alias. I had defined alias docker=docker.exe.
Removing that did it work again.
System & Environment
O.S.: Windows 10 Home, x64
Shell: Zsh (on Gitbash)

I think you may be missing ,'s in between each plugin.
plugins=(git, colored-man, colorize, github, jira, vagrant, virtualenv, pip, python, brew, osx, zsh-syntax-highlighting, docker)
Alternatively you can place each plugin on a separate line:
plugins=(
git
colored-man
colorize
github
jira
vagrant
virtualenv
pip
python
brew
osx
zsh-syntax-highlighting
docker
)

Related

after installing oh-my-zsh on mac git branch don't show, but after .oh-my-zsh it works

macos BigSur
installed oh-my-zsh by sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
when I start terminal git branch don't show but after run .oh-my-zsh in shows.
How to do this automatically as earlier?
I uninstalled it, reinstalled it - nothing, the same problem
.zshrc:
export ZSH="/Users/*****/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
You do not have the git-promot plugin loaded.
You only have the git plugin loaded. Which provides nice shortcuts but no prompt info.
You need to edit the plugins values array to include it.
Find plugins=(git) in your above .zshrc file and replace it with.
plugins=(
git
git-prompt
)
It is worth noting that changes are not immediate after you make them, you will need to resource the .zshrc file by either starting a new terminal or running source ~/.zshrc.

Why can't zsh execute command compdef?

I have installed zsh and oh my zsh on Ubuntu 18.04. I would like to use autocompletion for kubectl. Therefore I have added source <(kubectl completion zsh) to my ~/.zshrc file.
On execution of this script zsh gets the following error:
complete:13: command not found: compdef
The kubectl documentation states that when one gets the error above, you should put the following on top of the .zshrc file:
autoload -Uz compinit
compinit
After doing this and restarting the terminal, I get the same error.
In a git-issue I found the following helped people with a common issue:
#This will perform chmod g-w for each file returned by compaudit to remove write access for group
compaudit | xargs -I % chmod g-w "%"
#This will perform chown to current user (Windows and Linux) for each file returned by compaudit
compaudit | xargs -I % chown $USER "%"
#Remove all dump files (which normally speed up initialization)
rm ~/.zcompdump*
#Regenerate completions file
compinit
zsh logs the following while running the script:
kubescript:12457: command not found: _bash_comp
Unfortunately this did not solve my problem. What else can I do to fix my issue? Or even still: what can I do to find out what is causing it?
I fixed the error by using the following code in .zshrc:
# K8s auto-complete
autoload -U +X compinit && compinit
source <(kubectl completion zsh)
You may also do it using oh-my-zsh plugin if you use oh-my-zsh.
I had the same issue and it was solved updating nvm
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
For my OSX 10.15.7 I did something similar
vi ~/.zshrc
alias k=kubectl
autoload -U +X compinit && compinit
[[ /usr/local/bin/kubectl ]] && source <(kubectl completion zsh)
Works like a charm!
I encountered this after installing the Angular CLI. Turns that Angular adds something into your .zshrc file.
If you recently installed Angular CLI, open ~/.zshrc and remove the lines added by Angular CLI.
After trying lot of options and going through diff treads. It worked for me after running below command
autoload -Uz compinstall && compinstall
This configures the ~/.zshrc and initialize the compinit by adding these 2 below lines:
autoload -Uz compinit
compinit
and then run below sudo commands which mentioned in link
$ sudo chmod -R 755 /usr/local/share/zsh
$ sudo chown -R root:staff /usr/local/share/zsh
$ compaudit | xargs chmod g-w
at last restart the terminal.
Hope this helps for someone.
In my case the issue was fixed after re-installing oh-my-zsh:
Deleted my old version rm -rf ~/.oh-my-zsh
Installed from https://github.com/ohmyzsh/ohmyzsh
I really tried every answer here, but nothing worked.
So, I tried this tutorial paying attention to the last observation:
"Note: Make sure you add this snippet before any call to compdef else you will still see the error"
I had a complete call from Terraform installation in my ~/.zshrc and ~/.bash_profile files.
https://thysmichels.com/2020/07/16/mac-solved-command-not-found-compdef/
For me I had this line:
source ~/.oh-my-zsh/plugins/git/git.plugin.zsh
In my ~/.zshrc file. Which was trying to source the plugin before it is loaded by plugins=(git)
Removing that line fixed it for me.
If you have added the plugins and everything works well, One of the reasons is you may be trying to use the plugin before it is loaded. As in my case.
This issue is (also) faced after installing Angular CLI (Angular Version 14.x) and accepting addition of autocompletion for the cli commands. Snippet from .zshrc:
# Load Angular CLI autocompletion.
source <(ng completion script)
Commenting out the source line resolved the issue for me (macOS 12.6 (21G115)).
# Load Angular CLI autocompletion.
# source <(ng completion script)
Still need to work out the root cause.

Cursor keys dont work in vim when running zsh on wsl through cmder or conemu

I'm running ubuntu 1804 on windows using the WSL. Everything is set up fine and works correctly. I've also installed ZSH and oh-my-zsh, again this is all good and everything looks like its working fine. Everything except the arrow keys whilst using vim or man pages or some other command line tools.
The up and down keys work on the command line when scrolling through history and also for select commands like nano. Also if I boot into bash rather than zsh the arrow keys do work in vim and man pages, in fact they work everywhere.
If i boot into bash, then switch to zsh on the command line manually the arrow keys then work everywhere.
So my cmder config for zsh
c:/_distros/ubuntu1804/ubuntu1804.exe -c zsh -cur_console:pm
and for bash
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pm:/mnt
The one for bash uses the conemu-cyg-64.exe program that comes from conemu which is a symbiont of POSIX enabled pty and WinAPI full-featured terminal.
Apparently you can use this tool with zsh but i cant manage to make it work i get the error
{PID:10592} failed to run shell (2): No such file or directory
{PID:10592} shell: `/usr/bin/zsh` `-l` `-i`
{PID:10592} dir: `/cygdrive/c/Program Files/cmder`
ConEmuC: Root process was alive less than 10 sec, ExitCode=0.
Press Enter or Esc to close console...
and this is the task in cmder
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe /usr/bin/zsh -l -i -cur_console:pm:/mnt
So I think that if i can boot into zsh using conemu-cyg-64 that the cursor keys will probably work in commands like vim and the man pages. Any help or advice getting that working would be brilliant.
EDIT:
On my ubuntu install zsh is installed at /usr/bin/zsh, but there is no file or folder /cygdrive/c/Program Files/cmder
Many thanks to #Maximus for pointing me in the right direction. The answer was right under my nose at the bash on windows page of conemu. A small change to the command i was using before. the zsh needs to go on the end rather than before the --wsl.
The correct task to ensure that cursor keys work on all apps in the terminal is:
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pnm:/mnt -t zsh -l

How to hide terminal warning when Oh-my-ZSH plugin can't access external app

I've been using oh-my-zsh for a while and it's working great. I'd like to use the command-line fuzzy finder plugin so I enabled it in .zshrc:
plugins=(fzf)
However if "fzf" is not installed I get a warning when opening my terminal window:
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
Please add export FZF_BASE=/path/to/fzf/install/dir to your .zshrc
Is there a way to hide that warning message? When I install fzf with "sudo dnf install fzf" the warning dissapears, but maybe I want to clone my dotfiles on a different computer where it is not available and it's not that important to be there.
you should first install fzf, in Mac and i use the following command to install brew install fzf
You need to have fzf installed to use this plugin; otherwise remove it. It won't do anything without first installing fzf. Sudo apt install fzf
You can put the plugins= line inside an if statement that checks for the presence of fzf in your path. For example:
if [[ -n $(command -v fzf) ]] ; then
echo "fzf found, loading oh-my-zsh fzf plugin"
plugins=(vi-mode fzf)
else
echo "no fzf was found in the path"
plugins=(vi-mode)
fi
command -v is similar to which, but is superior for this context as explained in this answer.
The -n makes the [[ ]] evaluate as true whenever the $() produces a non-empty output.
For me, it was also very important that brew itself was in Path of ~/.zshenv like so:
export PATH=/opt/homebrew/bin:$PATH
Installed FZF with brew on an M1 Mac.
Otherwise, the error occurs:
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
Please add `export FZF_BASE=/path/to/fzf/install/dir` to your .zshrc
When you install fzf by using brew, it needs to be set brew env.
You can solve to set PATH for fzf before the line of plugins=(fzf) in .zshrc file.
But, I recommand creating "$HOME/.zprofile" as following.
For m1 Mac.
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/opt/homebrew/bin/brew shellenv)"
For, intel Mac
# Set PATH, MANPATH, etc., for Homebrew.
eval "$(/usr/local/bin/brew shellenv)"

'RM' is not recognized as an internal or external command while using Meteor on Windows

i am currently having problem with 'meteor' and i am currently new to this learning this stuff. So, after installing 'Meteor' i opened command prompt on Windows and typed :
meteor create goodboy
and then,
cd goodboy
But to delete the live and already running example app, i used :
rm goodboy.*
But the command prompt, gave this error :
rm is not recognized as an internal or external command, operable
program or batch file.
Is there anyway i can fix this error, thank you.
Use del on Windows.
Also, this has nothing to do with Meteor. You can also delete a Meteor project by going to the folder and dragging it to the trash.
If you are on windows, git bash may run such commands.
If you are using Mac then we can simply use
rm -f src/*
and For windows we can use command for this is
del -f "src/*"
Hope this works fine for you.
Download and Extract PortableGit.
This has most of commonly used Linux based tools ported to windows.
Add [PortableGit Path]\usr\bin to PATH variable of Windows
You can also use your system's Git installation instead of PortableGit.
This should solve the problem
I'm running Git shell prompt and for some reason it doesn't have it any more. I ended up using Cygin to get it working:
https://www.cygwin.com/
My penny's worth.
You could potentially add rm to powershell. In your (or a) profile.ps1 (or other if your powershell is not core).
rm {
del
}
or as an alias
Set-Alias rm del
or (and this is a tricky one), run WSL, bind the target folder and run via the linux interface.
PS: running the command via the Git Bash (MINGW64) terminal as suggested above, did the trick for me.
I guess you are not using bash terminal. Try this..
1- Go to the folder that you want to remove its contents lets call it my-app folder.
2- Right click in the empty space, then choose get Bash here.
3- Paste the command rm -f A_folder/* (I'm about to remove the content inside A_folder folder which is a sub-folder inside my-app).
4- Hit enter.
That should remove all content from A_folder folder.
Hope that helps.
I guess you are not using the Git Bash terminal but the normal command prompt.
Do try the same on the Git Bash terminal and you would not face this error anymore.
first, install linux clients for windows, I use Ubunto LTS
then install node.js and run your command again.
here, you find good instructions to do it so, as well as how to install cool new Windows Terminal
you should add
"remove-build": "rmdir /s /q build",
"create-build": "mkdir build",
"clean": "npm run remove-build && npm run create-build",
in package.json

Resources