Skip to content

Instantly share code, notes, and snippets.

@e-roux
Last active May 22, 2019 10:33
Show Gist options
  • Select an option

  • Save e-roux/2d5d38c341f6e044f4174384d3ab65d1 to your computer and use it in GitHub Desktop.

Select an option

Save e-roux/2d5d38c341f6e044f4174384d3ab65d1 to your computer and use it in GitHub Desktop.
Mémos

Launchctl

From man launchctl:

 ~/Library/LaunchAgents         Per-user agents provided by the user.
 /Library/LaunchAgents          Per-user agents provided by the administrator.
 /Library/LaunchDaemons         System wide daemons provided by the administrator.
 /System/Library/LaunchAgents   OS X Per-user agents.
 /System/Library/LaunchDaemons  OS X System wide daemons

/etc/profile

/etc/profile is the system-wide .profile file for the Bourne shell and Bourne compatible shells

  • On ubuntu, the PATH environment variable is being set in this file, then /etc/bash.bashrc and every readable files in /etc/profile.d will be loaded.
  • On mac OS, /usr/libexec/path_helper is beeing exectued for setting the $PATH environment variable, then /etc/bashrc and later on terminal specific configuration /etc/bashrc_${TERM_PROGRAM} will be loaded

macOS

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
    eval `/usr/libexec/path_helper -s`
fi

if [ "${BASH-no}" != "no" ]; then
    [ -r /etc/bashrc ] && . /etc/bashrc
fi

macOS delivers an utility /usr/libexec/path_helper for printing and exporting system wide PATH configured in /etc

PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:~/.local/bin:/opt/X11/bin"; export PATH;

A simulated behavior can be

#!/bin/bash -

declare -a path_dirs

while read -r dir ; do
    if [ "${#path_dirs[@]}" == "0" ]; then
        path_dirs=${dir}
    else
        path_dirs+=":${dir}"
    fi
done <<(/bin/cat /etc/paths $(find /etc/paths.d -type f -iname "*[^~]") 2> /dev/null)

echo "PATH=\"${path_dirs[@]}\"; export PATH;"

# EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment