Skip to content

Commit 454ff9c

Browse files
committed
Support both Apple Silicon and Intel in Homebrew
1 parent dd3fa32 commit 454ff9c

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SHELL = /bin/bash
22
DOTFILES_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
33
OS := $(shell bin/is-supported bin/is-macos macos linux)
44
PATH := $(DOTFILES_DIR)/bin:$(PATH)
5+
HOMEBREW_PREFIX := $(shell bin/is-supported bin/is-arm64 /opt/homebrew /usr/local)
56
export XDG_CONFIG_HOME = $(HOME)/.config
67
export STOW_DIR = $(DOTFILES_DIR)
78
export ACCEPT_EULA=Y
@@ -51,7 +52,7 @@ unlink: stow-$(OS)
5152
brew:
5253
is-executable brew || curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash
5354

54-
bash: BASH=/usr/local/bin/bash
55+
bash: BASH=$(HOMEBREW_PREFIX)/bin/bash
5556
bash: SHELLS=/private/etc/shells
5657
bash: brew
5758
ifdef GITHUB_ACTION

bin/is-arm64

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ "$(uname -m)" == "arm64" ]]; then
4+
exit 0
5+
else
6+
exit 1
7+
fi

runcom/.bash_profile

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
[ -z "$PS1" ] && return
44

55
# Resolve DOTFILES_DIR (assuming ~/.dotfiles on distros without readlink and/or $BASH_SOURCE/$0)
6-
7-
READLINK=$(which greadlink 2>/dev/null || which readlink)
86
CURRENT_SCRIPT=$BASH_SOURCE
97

10-
if [[ -n $CURRENT_SCRIPT && -x "$READLINK" ]]; then
11-
SCRIPT_PATH=$($READLINK -f "$CURRENT_SCRIPT")
12-
DOTFILES_DIR=$(dirname "$(dirname "$SCRIPT_PATH")")
8+
if [[ -n $CURRENT_SCRIPT && -x readlink ]]; then
9+
SCRIPT_PATH=$(readlink -n $CURRENT_SCRIPT)
10+
DOTFILES_DIR="${PWD}/$(dirname $(dirname $SCRIPT_PATH))"
1311
elif [ -d "$HOME/.dotfiles" ]; then
1412
DOTFILES_DIR="$HOME/.dotfiles"
1513
else
@@ -49,7 +47,7 @@ fi
4947

5048
# Clean up
5149

52-
unset READLINK CURRENT_SCRIPT SCRIPT_PATH DOTFILE EXTRAFILE
50+
unset CURRENT_SCRIPT SCRIPT_PATH DOTFILE EXTRAFILE
5351

5452
# Export
5553

system/.path

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33

44
is-executable getconf && PATH=$($(command -v getconf) PATH)
55

6+
export HOMEBREW_PREFIX=$($DOTFILES_DIR/bin/is-supported $DOTFILES_DIR/bin/is-arm64 /opt/homebrew /usr/local)
7+
68
# Prepend new items to path (if directory exists)
79

810
prepend-path "/bin"
911
prepend-path "/usr/bin"
10-
prepend-path "/usr/local/bin"
11-
prepend-path "/usr/local/opt/coreutils/libexec/gnubin"
12-
prepend-path "/usr/local/opt/gnu-sed/libexec/gnubin"
13-
prepend-path "/usr/local/opt/grep/libexec/gnubin"
12+
prepend-path "$HOMEBREW_PREFIX/bin"
13+
prepend-path "$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin"
14+
prepend-path "$HOMEBREW_PREFIX/opt/gnu-sed/libexec/gnubin"
15+
prepend-path "$HOMEBREW_PREFIX/opt/grep/libexec/gnubin"
1416
prepend-path "/usr/local/opt/python/libexec/bin"
1517
prepend-path "/usr/local/opt/ruby/bin"
1618
prepend-path "$DOTFILES_DIR/bin"

0 commit comments

Comments
 (0)