Skip to content

romanr/macos-disable-path_helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Automated Disabler of macOS path_helper for zsh

macOS has path_helper utility that rearranges shell PATH environment causing all kinds of problems. The path_helper is run at zsh startup from /etc/zprofile and you can just comment it out there to disable safely.

The issue is that macOS updates overwrite /etc/zprofile. This script automatically comments out path_helper in /etc/zprofile and being called at zsh startup it watches that file, and if change is detected, prompts to automatically disable the path_helper again.

Install

  1. Copy zsh_path_helper_disable.zsh to your home directory:

    cp zsh_path_helper_disable.zsh "$HOME/.zsh_path_helper_disable"
  2. Add to your ~/.zshenv:

    echo '[ -f "$HOME/.zsh_path_helper_disable" ] && . "$HOME/.zsh_path_helper_disable"' >> ~/.zshenv

    or insert this manually in the beginnign of ~/.zshenv:

    [ -f "$HOME/.zsh_path_helper_disable" ] && . "$HOME/.zsh_path_helper_disable"
  3. Open a new terminal or run source ~/.zshenv to activate.

How it works

  • On each shell startup, the script checks if /etc/zprofile has changed (using crc32).
  • If /etc/zprofile has not been checked or has changed, it prompts you to comment out path_helper in /etc/zprofile (requires sudo).
  • If you confirm, it comments out the relevant line, updates the checksum, and notifies you to reopen your shell.
  • Operations done using sudo so you will be asked to authenticate
  • backup /etc/zprofile.bak is automatically created

Uninstall

  • Remove the line from your ~/.zshenv.

  • Delete .zsh_path_helper_disable and .zsh_path_helper_disable_state from your home directory:

    rm ~/.zsh_path_helper_disable
    rm ~/.zsh_path_helper_disable_state
  • Optionally restore /etc/zprofile:

    sudo cp /etc/zprofile.bak /etc/zprofile

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages