Skip to content

Commit

Permalink
Install dev tools using asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
stefaniuk committed May 26, 2023
1 parent 4d4c5dd commit dc4837d
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 158 deletions.
12 changes: 8 additions & 4 deletions assets/02-install-base-packages.macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,27 @@ set -e

function main {

# Customise brew execution
export HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && export install="reinstall --force" || export install="install"

install
}

function install {

# Customise brew execution
HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && install="reinstall --force" || install="install"

# Install packages for consistent GNU/Linux-like CLI experience on macOS
brew $install \
ack \
autoconf \
bash \
binutils \
coreutils \
ctop \
curl \
diff-so-fancy \
diffutils \
dive \
findutils \
gawk \
git \
Expand All @@ -52,10 +54,12 @@ function install {
jq \
less \
make \
neovim \
openssl \
readline \
ripgrep \
screen \
shellcheck \
tmux \
tree \
watch \
Expand Down
148 changes: 114 additions & 34 deletions assets/03-install-developer-tools.macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ set -e

function main {

# Customise brew execution
export HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && export install="reinstall --force" || export install="install"

config-zsh
config-git
install-apps
install-tech-terraform
install-tools-and-apps

tech-terraform-install
tech-terraform-configure
tech-python-install
tech-python-configure
tech-npm-install
tech-npm-configure
tech-golang-install
tech-golang-configure
}

function config-zsh {
Expand All @@ -28,11 +40,9 @@ function config-zsh {
cat /etc/shells | grep $(brew --prefix)/bin/zsh > /dev/null 2>&1 || sudo sh -c "echo $(brew --prefix)/bin/zsh >> /etc/shells"
chsh -s $(brew --prefix)/bin/zsh
# Install oh-my-zsh
if (is-arg-true "$REINSTALL") then
rm -rf "$HOME/.oh-my-zsh"
fi
is-arg-true "$REINSTALL" && rm -rf "$HOME/.oh-my-zsh" ||:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended ||:
# Install powerlevel10k theme for zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended ||:
if [ -d "$HOME/.oh-my-zsh/custom/themes/powerlevel10k" ]; then
(
cd "$HOME/.oh-my-zsh/custom/themes/powerlevel10k"
Expand All @@ -41,34 +51,21 @@ function config-zsh {
else
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$HOME/.oh-my-zsh/custom/themes/powerlevel10k" ||:
fi
# Install vscode extensions
is-arg-true "$REINSTALL" && vs_ext_force="--force" || vs_ext_force=""
for file in $(cat "${CHEZMOI_SOURCE_DIR:-$(chezmoi source-path)}/.vscode/extensions.json" | jq '.recommendations[]' --raw-output); do
code $vs_ext_force --install-extension $file ||:
done
# Install iTerm theme
defaults import \
com.googlecode.iterm2 \
"${CHEZMOI_SOURCE_DIR:-$(chezmoi source-path)}/assets/iterm2/settings.xml"
}

function config-git {

mkdir -p ~/.gnupg
sed -i '/^pinentry-program/d' ~/.gnupg/gpg-agent.conf 2>/dev/null ||:
echo "pinentry-program $(whereis -q pinentry)" >> ~/.gnupg/gpg-agent.conf
sed -i '/^default-cache-ttl/d' ~/.gnupg/gpg-agent.conf
echo "default-cache-ttl 10800" >> ~/.gnupg/gpg-agent.conf
sed -i '/^max-cache-ttl/d' ~/.gnupg/gpg-agent.conf
echo "max-cache-ttl 10800" >> ~/.gnupg/gpg-agent.conf
mkdir -p "$HOME/.gnupg"
sed -i '/^pinentry-program/d' "$HOME/.gnupg/gpg-agent.conf" 2>/dev/null ||:
echo "pinentry-program $(whereis -q pinentry)" >> "$HOME/.gnupg/gpg-agent.conf"
sed -i '/^default-cache-ttl/d' "$HOME/.gnupg/gpg-agent.conf"
echo "default-cache-ttl 10800" >> "$HOME/.gnupg/gpg-agent.conf"
sed -i '/^max-cache-ttl/d' "$HOME/.gnupg/gpg-agent.conf"
echo "max-cache-ttl 10800" >> "$HOME/.gnupg/gpg-agent.conf"
gpgconf --kill gpg-agent
}

function install-apps {

# Customise brew execution
HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && install="reinstall --force" || install="install"
function install-tools-and-apps {

# Install developer apps
brew $install \
Expand All @@ -87,19 +84,102 @@ function install-apps {
brave-browser \
docker \
firefox \
font-hack-nerd-font \
google-chrome \
||:

# Install vscode extensions
is-arg-true "$REINSTALL" && vs_ext_force="--force" || vs_ext_force=""
for file in $(cat "${CHEZMOI_SOURCE_DIR:-$(chezmoi source-path)}/.vscode/extensions.json" | jq '.recommendations[]' --raw-output); do
code $vs_ext_force --install-extension $file ||:
done
# Install iterm theme
defaults import \
com.googlecode.iterm2 \
"${CHEZMOI_SOURCE_DIR:-$(chezmoi source-path)}/assets/iterm2/settings.xml"

# Install asdf, SEE: https://asdf-vm.com/
if [ -d "$HOME/.asdf" ]; then
(
cd "$HOME/.asdf"
git pull
)
else
git clone --depth=1 https://github.com/asdf-vm/asdf.git "$HOME/.asdf" ||:
fi
asdf plugin update --all
}

function install-tech-terraform() {
function tech-terraform-install() {

# Customise brew execution
HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && install="reinstall --force" || install="install"
asdf plugin add terraform ||:
asdf install terraform latest
asdf global terraform latest
}

# Install developer apps
brew $install \
warrensbox/tap/tfswitch
function tech-terraform-configure() {

:
# TODO: Install dev tools for terraform
# brew $install \
# warrensbox/tap/tfswitch
}

function tech-python-install() {

asdf plugin add python ||:
asdf install python latest
asdf global python latest
}

function tech-python-configure() {

python -m ensurepip
python -m pip install --upgrade pip

# TODO: Install dev tools for python
# brew $install \
# pyenv \
# pyenv-virtualenv \
# python \
# virtualenv \
# ||:
# python -m pip install \
# bandit \
# black \
# bpython \
# coverage \
# flake8 \
# mypy \
# prospector \
# pycodestyle \
# pylama \
# pylint \
# pytest
}

function tech-npm-install() {

asdf plugin add nodejs ||:
asdf install nodejs latest
asdf global nodejs latest
}

function tech-npm-configure() {

npm install --global yarn
}

function tech-golang-install() {

asdf plugin add golang ||:
asdf install golang latest
asdf global golang latest
}

function tech-golang-configure() {

:
}

# ==============================================================================
Expand Down
8 changes: 4 additions & 4 deletions assets/04-install-corporate-apps.macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ set -e

function main {

# Customise brew execution
export HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && export install="reinstall --force" || export install="install"

install
}

function install {

# Customise brew execution
HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && install="reinstall --force" || install="install"

# Install developer apps
brew $install \
avast-security \
Expand Down
8 changes: 4 additions & 4 deletions assets/05-install-user-apps.macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ set -e

function main {

# Customise brew execution
export HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && export install="reinstall --force" || export install="install"

install
}

function install {

# Customise brew execution
HOMEBREW_NO_AUTO_UPDATE=1
is-arg-true "$REINSTALL" && install="reinstall --force" || install="install"

# Install developer apps
brew $install \
alt-tab \
Expand Down
21 changes: 21 additions & 0 deletions assets/vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
//
// Extensions settings
//
"cSpell.language": "en,en-GB",
"cSpell.enableFiletypes": [
"dockerfile",
Expand All @@ -10,7 +12,9 @@
],
"redhat.telemetry.enabled": false,
"todohighlight.keywords": ["SEE:"],
//
// General project settings
//
"breadcrumbs.enabled": true,
"editor.autoIndent": "full",
"editor.bracketPairColorization.enabled": true,
Expand All @@ -28,6 +32,20 @@
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.watcherExclude": {
"**/.git": true,
"**/log": true,
"**/node_modules": true,
"**/target": true,
"**/tmp": true
},
"search.exclude": {
"**/.git": true,
"**/log": true,
"**/node_modules": true,
"**/target": true,
"**/tmp": true
},
"terminal.integrated.fontFamily": "Hack Nerd Font",
"window.newWindowDimensions": "maximized",
"window.title": "${activeEditorMedium}${separator}${rootName}${separator}${rootPath}",
Expand All @@ -36,6 +54,9 @@
"workbench.editor.enablePreview": true,
"workbench.iconTheme": "vscode-icons",
"workbench.tree.indent": 20,
//
// Files settings
//
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
Expand Down
12 changes: 7 additions & 5 deletions dot_path.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{{- if eq .chezmoi.os "darwin" -}}
path_homebrew="/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/curl/bin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/gnu-getopt/bin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/gnu-tar/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/openssl/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/curl/bin:/usr/local/opt/findutils/libexec/gnubin:/usr/local/opt/gnu-getopt/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/make/libexec/gnubin:/usr/local/opt/openssl/bin:/opt/homebrew/bin:/usr/local/Homebrew/bin"
path_asdf="$HOME/.asdf/shims:$HOME/.asdf/bin"
path_docker="$HOME/.docker/bin"
path_packages="$path_homebrew:$path_docker"
path_default="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

{{ if eq .chezmoi.os "darwin" -}}
path_homebrew="/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/curl/bin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/gnu-getopt/bin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/gnu-tar/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/opt/make/libexec/gnubin:/opt/homebrew/opt/openssl/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/curl/bin:/usr/local/opt/findutils/libexec/gnubin:/usr/local/opt/gnu-getopt/bin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/make/libexec/gnubin:/usr/local/opt/openssl/bin:/opt/homebrew/bin:/usr/local/Homebrew/bin"
path_packages="$path_asdf:$path_docker:$path_homebrew"
{{- else if eq .chezmoi.os "linux" }}
path_packages=""
path_packages="$path_asdf:$path_docker"
{{- end }}
path_default="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"

export PATH="$HOME/bin:$HOME/.local/bin:$path_packages:$path_default"
Loading

0 comments on commit dc4837d

Please sign in to comment.