-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e07607c
commit fdeeac3
Showing
6 changed files
with
90 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env zsh | ||
|
||
# ----------------------------------- | ||
# author: @kiliantyler | ||
# title: Dotfiles Installation Script | ||
# description: Installs Xcode Command Line Tools if they are not already installed, | ||
# then installs Chezmoi and initializes it with my dotfiles. | ||
# ----------------------------------- | ||
|
||
fail() { | ||
echo "$1" >&2 | ||
exit 1 | ||
} | ||
|
||
# ----------------------------------- | ||
# Ensure we are running in zsh | ||
# Make this check POSIX compliant | ||
# ----------------------------------- | ||
|
||
if [ -z "${ZSH_VERSION:-}" ]; then | ||
fail "Please run this script in zsh" | ||
fi | ||
|
||
should_install_command_line_tools() { | ||
! [[ -e "/Library/Developer/CommandLineTools/usr/bin/git" ]] | ||
} | ||
|
||
chomp() { | ||
printf "%s" "${1/"$'\n'"/}" | ||
} | ||
|
||
# ----------------------------------- | ||
# Xcode Command Line Tools Installation | ||
# ----------------------------------- | ||
|
||
if should_install_command_line_tools; then | ||
echo "Installing Xcode Command Line Tools" | ||
# This temporary file prompts the 'softwareupdate' utility to list the Command Line Tools | ||
clt_placeholder="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress" | ||
command sudo touch "${clt_placeholder}" | ||
|
||
clt_label_command="/usr/sbin/softwareupdate -l | | ||
grep -B 1 -E 'Command Line Tools' | | ||
awk -F'*' '/^ *\\*/ {print \$2}' | | ||
sed -e 's/^ *Label: //' -e 's/^ *//' | | ||
sort -V | | ||
tail -n1" | ||
clt_label="$(chomp "$(/bin/bash -c "${clt_label_command}")")" | ||
|
||
if [[ -n ${clt_label} ]]; then | ||
command sudo "/usr/sbin/softwareupdate" "-i" "${clt_label}" | ||
command sudo "/usr/bin/xcode-select" "--switch" "/Library/Developer/CommandLineTools" | ||
fi | ||
command sudo "/bin/rm" "-f" "${clt_placeholder}" | ||
fi | ||
|
||
# ----------------------------------- | ||
# Chezmoi Installation and Initialization | ||
# ----------------------------------- | ||
|
||
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin init --apply kiliantyler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters