Skip to content

Commit

Permalink
fix: starting script fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kiliantyler committed Sep 4, 2024
1 parent e431af2 commit e07607c
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 167 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# -----------------------------------
# author: @kiliantyler
# title: Decrypt Age Key
# description: Decrypts the Age key used by chezmoi
# -----------------------------------

if [ ! -f "${HOME}/.config/chezmoi/key.txt" ]; then
mkdir -p "${HOME}/.config/chezmoi"
chezmoi age decrypt --output "${HOME}/.config/chezmoi/key.txt" --passphrase "{{ .chezmoi.sourceDir }}/key.txt.age"
Expand Down
59 changes: 59 additions & 0 deletions dotfiles/.chezmoiscripts/runOnce/run_once_before_1-darwin.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{{- if eq .chezmoi.os "darwin" -}}
#!/usr/bin/env zsh

# -----------------------------------
# author: @kiliantyler
# title: Installs Xcode Command Line Tools
# description: Installs Xcode Command Line Tools if they are not already installed
# -----------------------------------

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

{{ end }}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit e07607c

Please sign in to comment.