summaryrefslogtreecommitdiff
path: root/dotfiles-darwin/bin/env.sh
blob: 7a9d7e5a44ad3ab3930ee54227cd1565734b7c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env zsh

for env (DOMAIN HOST SSH_AUTH_SOCK UNAME
         XDG_{{CACHE,CONFIG,DATA}_HOME,RUNTIME_DIR}); do
  launchctl setenv ${env} ${(P)env}
done

# PATH is magic on macOS, and since it only matters for Emacs, let’s
# make it work in Emacs only. Yep, it’s pretty bad.
local plist=~/Applications/Emacs.app/Contents/Info.plist
if [[ -f ${plist} ]]; then
  plutil -replace LSEnvironment -dictionary ${plist}
  plutil -insert LSEnvironment.PATH -string "${PATH}" ${plist}
  /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f ${plist:h:h}
fi