Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for macOS #33

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
22 changes: 21 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,28 @@ jobs:
sh install.sh
yes | sudo sh install-system.sh

macos:
runs-on: macos-11
defaults:
run:
shell: bash
steps:
- name: Cancel previous runs
if: github.event_name == 'pull_request'
uses: styfle/[email protected]

- uses: actions/checkout@v2

- name: Install dotfiles
run: sh install.sh
shell: bash

- name: Ensure idempotency
run: sh install.sh
shell: bash

windows:
runs-on: windows-2019
runs-on: windows-2022
defaults:
run:
shell: bash
Expand Down
14 changes: 10 additions & 4 deletions lib/copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ set -o errexit
set -o nounset

copy() {
local source="$1"
local target="$2"
local mode=${3:-0644}
source=$1
target=$2
mode=${3:-0644}

# If the installed file is newer than the source one, do nothing
if test "$target" -nt "$source"; then
echo "--- Existing file $target is newer than source $source; skipping" >&2
return
fi

install --verbose --compare --backup --mode="$mode" --no-target-directory "$source" "$target"
OS=$(uname -s)
if [ "$OS" = "Darwin" ]; then
# Use Unix-style flags if we're running on macOS
install -vb -m "$mode" -p "$source" "$target"
else
install --verbose --compare --backup --mode="$mode" --no-target-directory "$source" "$target"
fi
}
13 changes: 9 additions & 4 deletions lib/link.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ set -o errexit
set -o nounset

link() {
local source="$1"
local target="$2"
source=$1
target=$2

if [ -L "$target" ]; then
# Resolve the link and ensure it's pointing to the correct location
local destination
destination=$(readlink "$target")
if [ "$destination" = "$source" ]; then
return 0
fi
fi

ln --symbolic --verbose --backup "$source" "$target"
OS=$(uname -s)
if [ "$OS" = "Darwin" ]; then
# Use Unix-style flags if we're running on macOS
ln -sfv "$source" "$target"
else
ln --symbolic --verbose --backup "$source" "$target"
fi
}
12 changes: 7 additions & 5 deletions lib/make_directory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ set -o errexit
set -o nounset

make_directory() {
local target="$1"
local mode=${2:-0755}
target=$1
mode=${2:-0755}

if [ -d "$target" ]; then
return
fi

local OS
OS=$(uname --operating-system)

OS=$(uname -s)
echo "OS: $OS"
if [ "$OS" = "Msys" ]; then
# mkdir on Windows fails with --mode
mkdir --verbose "$target"
elif [ "$OS" = "Darwin" ]; then
# Use Unix-style flags if we're running on macOS
mkdir -v -m "$mode" "$target"
else
mkdir --verbose --mode="$mode" "$target"
fi
Expand Down
5 changes: 2 additions & 3 deletions lib/prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ set -o errexit
set -o nounset

prompt() {
local question="$1"

local answer
question=$1
answer=

read -r -p "$question " answer
case "$answer" in
Expand Down
8 changes: 7 additions & 1 deletion lib/remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ remove() {
return
fi

rm --verbose "$target"
OS=$(uname -s)
if [ "$OS" = "Darwin" ]; then
# Use Unix-style flags if we're running on macOS
rm -v "$target"
else
rm --verbose "$target"
fi
}
5 changes: 4 additions & 1 deletion src/.bashrc.d/path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ add_if_exist "${HOME}/.local/bin"
# Node.js scripts
add_if_exist "${HOME}/.npm-packages/bin"

OS=$(uname --operating-system)
OS=$(uname -s)

# Running under mingw64, check for other software
if [ "$OS" = "Msys" ]; then
Expand All @@ -49,6 +49,9 @@ if [ "$OS" = "Msys" ]; then
add_if_exist "${ProgramFiles_x86}/Yarn/bin"

add_if_exist "${ProgramFiles_x86}/Google/Cloud SDK/google-cloud-sdk/bin"
elif [ "$OS" = "Darwin" ]; then
add_if_exist "/opt/homebrew/bin"
add_if_exist "/opt/homebrew/opt/coreutils/libexec/gnubin"
fi

# Go programs
Expand Down
1 change: 0 additions & 1 deletion src/.bashrc.d/prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ reset='\[\e[m\]'
normal_green='\[\e[0;32m\]'
normal_yellow='\[\e[0;33m\]'
normal_purple='\[\e[0;35m\]'
#normal_cyan='\[\e[0;36m\]'
bright_gray='\[\e[1;30m\]'
bright_red='\[\e[1;31m\]'
bright_yellow='\[\e[1;33m\]'
Expand Down