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 .env
*.log *.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 _ps="/bin/ps"
alias _dig=`which dig` alias _dig=`which dig`
alias _git=`which git` alias _git=`which git`
alias _readlink=`which readlink`
# Aliases # Aliases
alias cat='bat ' alias cat='bat '
@ -30,6 +31,7 @@ alias kctx='switch'
alias machine-info='macchina -t Boron --bar' alias machine-info='macchina -t Boron --bar'
alias watch='watch ' alias watch='watch '
alias tmp='cd $(mktemp -d)' alias tmp='cd $(mktemp -d)'
which greadlink &>/dev/null && alias readlink=`which greadlink`
lt() { lt() {
DEPTH=$(echo $1 | grep "^[0-9]*$") 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 ' alias kube-forward='kube-forward-all '
source <(kubectl completion zsh) 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] [user]
name = Marcus Noble name = Marcus Noble
email = github@marcusnoble.co.uk
signingkey = B8F2DB8A7AEBAF78 signingkey = B8F2DB8A7AEBAF78
[commit] [commit]

View File

@ -4,6 +4,7 @@ PATH_DIRS=(
"${GOPATH:-${HOME}/goworkspace}/bin" "${GOPATH:-${HOME}/goworkspace}/bin"
"${HOME}/.cargo/bin" "${HOME}/.cargo/bin"
"/home/linuxbrew/.linuxbrew/bin" "/home/linuxbrew/.linuxbrew/bin"
"/opt/homebrew/bin/"
"/usr/local/bin" "/usr/local/bin"
"/usr/bin" "/usr/bin"
"/bin" "/bin"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/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) GITEMAIL=$(git config --get user.email)
@ -13,13 +13,13 @@ echo "🔵 Setting up zsh"
# Install oh-my-zsh # Install oh-my-zsh
printf "Cloning 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" printf " ✅\n"
# Install ZSH plugins # Install ZSH plugins
printf "Cloning 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:-${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:-~/.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-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" printf " ✅\n"
# Install tools # Install tools
@ -61,16 +61,14 @@ do
printf " ✅\n" printf " ✅\n"
done done
echo "🔵 Adding configuration" fulllink() {
FILES=$(find ./home -maxdepth 1 -mindepth 1 -printf '%f ') if [ ! -z `which greadlink` ]
for file in $FILES then
do greadlink -f $1
f=$(readlink -f "./home/${file}") else
printf "Linking ${f}..." readlink -f $1
ln -sfn ${f} ~/$(basename "./home/${file}") fi
printf " ✅\n" }
done
echo "🔵 OS Specific setup" echo "🔵 OS Specific setup"
echo "Detected OS type: ${OSTYPE}" echo "Detected OS type: ${OSTYPE}"
@ -81,21 +79,43 @@ case "${OSTYPE}" in
;; ;;
*darwin*) *darwin*)
# Mac specific setup # Mac specific setup
BREW_TOOLS=( pinentry-mac gpg gawk coreutils ) MAC_BREW_TOOLS=( pinentry-mac gpg gawk coreutils )
for tool in "${MAC_BREW_TOOLS[@]}" for tool in "${MAC_BREW_TOOLS[@]}"
do do
printf "${tool}..." printf "${tool}..."
brew upgrade ${tool} &>/dev/null || brew install ${tool} &>/dev/null brew upgrade ${tool} &>/dev/null || brew install ${tool} &>/dev/null
printf " ✅\n" printf " ✅\n"
done 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 for file in $FILES
do do
f=$(readlink -f "./os-specific/darwin/home/${file}") f=$(fulllink "${file}")
printf "Linking ${f}..." dst="${HOME}/$(basename "./os-specific/darwin/home/${file}")"
ln -sfn ${f} ~/$(basename "./os-specific/darwin/home/${file}") printf "Linking ${f}=>${dst}"
ln -sfn ${f} ${dst}
printf " ✅\n" printf " ✅\n"
done 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 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