From 57ee2084079b56033e9c3f353e52e70ce5fc49d3 Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Fri, 3 Dec 2021 17:12:52 +0000 Subject: [PATCH] Fixed for MacOS Signed-off-by: Marcus Noble --- .gitignore | 3 ++ home/.dotfiles/aliases | 2 ++ home/.dotfiles/kubernetes | 4 ++- home/.gitconfig | 1 + home/.zshrc | 1 + install.sh | 58 ++++++++++++++++++++++++++------------- 6 files changed, 49 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index ddf3f40..7878e94 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ .env *.log + +/os-specific/darwin/home/.gnupg/* +!/os-specific/darwin/home/.gnupg/gpg-agent.conf diff --git a/home/.dotfiles/aliases b/home/.dotfiles/aliases index 2faaea1..54e3282 100644 --- a/home/.dotfiles/aliases +++ b/home/.dotfiles/aliases @@ -11,6 +11,7 @@ alias _top=`which top` alias _ps="/bin/ps" alias _dig=`which dig` alias _git=`which git` +alias _readlink=`which readlink` # Aliases alias cat='bat ' @@ -30,6 +31,7 @@ alias kctx='switch' alias machine-info='macchina -t Boron --bar' alias watch='watch ' alias tmp='cd $(mktemp -d)' +which greadlink &>/dev/null && alias readlink=`which greadlink` lt() { DEPTH=$(echo $1 | grep "^[0-9]*$") diff --git a/home/.dotfiles/kubernetes b/home/.dotfiles/kubernetes index 0fee23e..bbbc4fc 100644 --- a/home/.dotfiles/kubernetes +++ b/home/.dotfiles/kubernetes @@ -7,4 +7,6 @@ alias fix-broken-replicasets='kube-clean-replicasets ' alias kube-forward='kube-forward-all ' source <(kubectl completion zsh) -source <(tkn completion zsh) +# tkn currently doesn't work with Mac ARM chips +# source <(tkn completion zsh) + diff --git a/home/.gitconfig b/home/.gitconfig index 95bf327..ace0491 100644 --- a/home/.gitconfig +++ b/home/.gitconfig @@ -1,5 +1,6 @@ [user] name = Marcus Noble + email = github@marcusnoble.co.uk signingkey = B8F2DB8A7AEBAF78 [commit] diff --git a/home/.zshrc b/home/.zshrc index 8ebca99..720b9bb 100644 --- a/home/.zshrc +++ b/home/.zshrc @@ -4,6 +4,7 @@ PATH_DIRS=( "${GOPATH:-${HOME}/goworkspace}/bin" "${HOME}/.cargo/bin" "/home/linuxbrew/.linuxbrew/bin" + "/opt/homebrew/bin/" "/usr/local/bin" "/usr/bin" "/bin" diff --git a/install.sh b/install.sh index 8ce50f1..88e3f78 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export PATH="/home/linuxbrew/.linuxbrew/bin:$PATH" +export PATH="/home/linuxbrew/.linuxbrew/bin:/opt/homebrew/bin/:$PATH" GITEMAIL=$(git config --get user.email) @@ -13,13 +13,13 @@ echo "🔵 Setting up zsh" # Install oh-my-zsh printf "Cloning oh-my-zsh..." -[ -d ~/.oh-my-zsh ] || sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +[ -d ${HOME}/.oh-my-zsh ] || sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" printf " ✅\n" # Install ZSH plugins printf "Cloning zsh plugins..." -[ -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ] || git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -[ -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting +[ -d ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ] || git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-autosuggestions +[ -d ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting printf " ✅\n" # Install tools @@ -61,16 +61,14 @@ do printf " ✅\n" done -echo "🔵 Adding configuration" -FILES=$(find ./home -maxdepth 1 -mindepth 1 -printf '%f ') -for file in $FILES -do - f=$(readlink -f "./home/${file}") - printf "Linking ${f}..." - ln -sfn ${f} ~/$(basename "./home/${file}") - printf " ✅\n" -done - +fulllink() { + if [ ! -z `which greadlink` ] + then + greadlink -f $1 + else + readlink -f $1 + fi +} echo "🔵 OS Specific setup" echo "Detected OS type: ${OSTYPE}" @@ -81,21 +79,43 @@ case "${OSTYPE}" in ;; *darwin*) # Mac specific setup - BREW_TOOLS=( pinentry-mac gpg gawk coreutils ) + MAC_BREW_TOOLS=( pinentry-mac gpg gawk coreutils ) for tool in "${MAC_BREW_TOOLS[@]}" do printf "${tool}..." brew upgrade ${tool} &>/dev/null || brew install ${tool} &>/dev/null printf " ✅\n" done + - FILES=$(find ./os-specific/darwin/home -maxdepth 1 -mindepth 1 -printf '%f ') + FILES=$(find ./os-specific/darwin/home -maxdepth 1 -mindepth 1 | tr '\n' ' ') for file in $FILES do - f=$(readlink -f "./os-specific/darwin/home/${file}") - printf "Linking ${f}..." - ln -sfn ${f} ~/$(basename "./os-specific/darwin/home/${file}") + f=$(fulllink "${file}") + dst="${HOME}/$(basename "./os-specific/darwin/home/${file}")" + printf "Linking ${f}=>${dst}" + ln -sfn ${f} ${dst} printf " ✅\n" done + + [ -f "/usr/local/bin/pinentry-mac" ] || sudo ln -s `which pinentry-mac` /usr/local/bin/pinentry-mac + gpgconf --kill gpg-agent + + if [ $(gpg --list-secret-keys --keyid-format=long 2>/dev/null | wc -l | xargs) -eq 0 ]; then + echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️" + echo "⚠️ You'll need to create a new GPG key ⚠️" + echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️" + fi ;; esac + +echo "🔵 Adding configuration" +FILES=$(find ./home -maxdepth 1 -mindepth 1 | tr '\n' ' ') +for file in $FILES +do + f=$(fulllink "${file}") + dst="${HOME}/$(basename "./home/${file}")" + printf "Linking ${f}=>${dst}" + ln -sfn ${f} ${dst} + printf " ✅\n" +done \ No newline at end of file