Skip to content

novotnyllc/path-from-login-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

path-from-login-shell

Set the macOS launchd user PATH from a zsh login shell, so GUI apps launched from Finder, Spotlight, Dock, and other launchd-managed contexts can see the same command-line tools as a terminal login shell.

This is useful for desktop apps that run tools such as gh, node, dotnet, rp-cli, brew, or other binaries installed through Homebrew, user-local toolchains, or language package managers.

How It Works

The LaunchAgent runs at login:

/bin/zsh -lc 'launchctl setenv PATH "$PATH"'

That asks zsh to build the login-shell PATH from normal startup files such as .zprofile, then writes that value into the current user's launchd environment.

Install

./scripts/install.sh

The installer copies launch-agents/local.path-from-login-shell.plist to:

~/Library/LaunchAgents/local.path-from-login-shell.plist

Then it loads and kickstarts the LaunchAgent for the current login session.

Uninstall

./scripts/uninstall.sh

This unloads the LaunchAgent and removes the installed plist. It leaves the current launchd PATH value alone by default.

To also clear the current launchd PATH value:

./scripts/uninstall.sh --unset-current

Shell Startup Guidance

Keep PATH construction in a login-shell-safe startup file, normally .zprofile.

Good candidates:

  • Homebrew brew shellenv
  • Tool directories such as $HOME/.local/bin, $HOME/.dotnet/tools, $HOME/.bun/bin
  • Static exports that are safe in non-interactive shells

Avoid putting interactive-only setup in .zprofile, because this agent runs a non-interactive login shell. Put prompts, aliases, terminal UI setup, and completions in .zshrc.

Verify

launchctl getenv PATH
/bin/zsh -lc 'printf "%s\n" "$PATH"'

Those should match closely. A running app may need to be restarted before it sees a changed launchd environment.

About

Sync macOS GUI app PATH from the zsh login shell

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages