Fixed for MacOS

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2021-12-03 17:12:52 +00:00
parent 3990c8fd9c
commit 57ee208407
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78
6 changed files with 49 additions and 20 deletions

3
.gitignore vendored
View File

@ -22,3 +22,6 @@
.env
*.log
/os-specific/darwin/home/.gnupg/*
!/os-specific/darwin/home/.gnupg/gpg-agent.conf

View File

@ -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]*$")

View File

@ -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)

View File

@ -1,5 +1,6 @@
[user]
name = Marcus Noble
email = github@marcusnoble.co.uk
signingkey = B8F2DB8A7AEBAF78
[commit]

View File

@ -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"

View File

@ -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