Wednesday, 16 March 2022

ZSH and Git and auto-complete

Having finally made the switch to ZSH ( zsh ) on my Mac a few weeks back ( yeah, I know, right ? ), I've been tinkering with auto-complete etc.

Lots of advice and guidance online, the simplest solution was to install zsh-completions, as I'm already using Homebrew: -

brew install zsh-completions

This, in part, said: -

To activate these completions, add the following to your .zshrc:

  if type brew &>/dev/null; then
    FPATH=$(brew --prefix)/share/zsh-completions:$FPATH

    autoload -Uz compinit
    compinit
  fi

You may also need to force rebuild `zcompdump`:

  rm -f ~/.zcompdump; compinit

Additionally, if you receive "zsh compinit: insecure directories" warnings when attempting
to load these completions, you may need to run this:

  chmod -R go-w '/usr/local/share/zsh'

Now I didn't read the last part ......

And then I noticed this: -

compinit
   
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]? y%                                                                                                                                                                 

A little digging later, I found compaudit, which reported: -

There are insecure directories:
/usr/local/share

and then I re-read the output from the brew command ...

Additionally, if you receive "zsh compinit: insecure directories" warnings when attempting
to load these completions, you may need to run this:

  chmod -R go-w '/usr/local/share/zsh'

but that made no difference - I still saw the same output from compaudit.

Eventually, I found this: -

compaudit | xargs chmod g-w

via this: -


TL;DR; this was the before state: -

ls -al /usr/local/share/zsh

total 0
drwxr-xr-x   3 hayd  admin    96 28 Jan  2019 .
drwxrwxr-x  36 hayd  admin  1152 16 Mar 09:55 ..
drwxr-xr-x  12 hayd  admin   384 15 Mar 12:23 site-functions

and this was the after state: -

ls -al /usr/local/share/zsh

total 0
drwxr-xr-x   3 hayd  admin    96 28 Jan  2019 .
drwxr-xr-x  36 hayd  admin  1152 16 Mar 09:55 ..
drwxr-xr-x  12 hayd  admin   384 15 Mar 12:23 site-functions

In other words, the chmod command removed the group-writeable permissions from the top-level directory - /usr/local/share

This was a good reminder of how one sees permissions using ls: -



No comments:

More fun with pip

Again with the Python and pip  fun, this time on my Mac, where commands such as:  pip3 list and: - pip3 install --upgrade pip were failing w...