Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions sh/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ fi

# Development tool configurations
export USE_CCACHE=1

# GUI terminals inherit launchd's tiny 256-file soft limit on macOS. Raise
# the shell limit before starting watcher-heavy tools such as moon and Next.js.
if is_macos; then
_desired_open_files=65536
_current_open_files="$(ulimit -Sn)"
_hard_open_files="$(ulimit -Hn)"

if [[ "${_hard_open_files}" != "unlimited" &&
"${_hard_open_files}" -lt "${_desired_open_files}" ]]; then
_desired_open_files="${_hard_open_files}"
fi

if [[ "${_current_open_files}" != "unlimited" &&
"${_current_open_files}" -lt "${_desired_open_files}" ]]; then
ulimit -Sn "${_desired_open_files}" 2> /dev/null || true
fi

unset _desired_open_files _current_open_files _hard_open_files
fi

# Resolve ccache rather than hardcoding /usr/bin/ccache, which does not exist
# on Homebrew installs.
if has_command ccache; then
Expand Down
Loading