diff --git a/assets/02-install-base-packages.macos.sh b/assets/02-install-base-packages.macos.sh index f1fa915..e255ff0 100755 --- a/assets/02-install-base-packages.macos.sh +++ b/assets/02-install-base-packages.macos.sh @@ -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 packages for consistent GNU/Linux-like CLI experience on macOS brew $install \ ack \ @@ -32,9 +32,11 @@ function install { bash \ binutils \ coreutils \ + ctop \ curl \ diff-so-fancy \ diffutils \ + dive \ findutils \ gawk \ git \ @@ -52,10 +54,12 @@ function install { jq \ less \ make \ + neovim \ openssl \ readline \ ripgrep \ screen \ + shellcheck \ tmux \ tree \ watch \ diff --git a/assets/03-install-developer-tools.macos.sh b/assets/03-install-developer-tools.macos.sh index 5fa8fdc..98c4ba2 100755 --- a/assets/03-install-developer-tools.macos.sh +++ b/assets/03-install-developer-tools.macos.sh @@ -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 { @@ -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" @@ -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 \ @@ -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() { + + : } # ============================================================================== diff --git a/assets/04-install-corporate-apps.macos.sh b/assets/04-install-corporate-apps.macos.sh index 41740b5..5067f6c 100755 --- a/assets/04-install-corporate-apps.macos.sh +++ b/assets/04-install-corporate-apps.macos.sh @@ -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 \ diff --git a/assets/05-install-user-apps.macos.sh b/assets/05-install-user-apps.macos.sh index 116ec97..2d38a29 100755 --- a/assets/05-install-user-apps.macos.sh +++ b/assets/05-install-user-apps.macos.sh @@ -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 \ diff --git a/assets/vscode/settings.json b/assets/vscode/settings.json index 9b8ecfb..a02a85d 100644 --- a/assets/vscode/settings.json +++ b/assets/vscode/settings.json @@ -1,5 +1,7 @@ { + // // Extensions settings + // "cSpell.language": "en,en-GB", "cSpell.enableFiletypes": [ "dockerfile", @@ -10,7 +12,9 @@ ], "redhat.telemetry.enabled": false, "todohighlight.keywords": ["SEE:"], + // // General project settings + // "breadcrumbs.enabled": true, "editor.autoIndent": "full", "editor.bracketPairColorization.enabled": true, @@ -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}", @@ -36,6 +54,9 @@ "workbench.editor.enablePreview": true, "workbench.iconTheme": "vscode-icons", "workbench.tree.indent": 20, + // + // Files settings + // "[jsonc]": { "editor.defaultFormatter": "esbenp.prettier-vscode" } diff --git a/dot_path.tmpl b/dot_path.tmpl index 389aee6..bf178d1 100644 --- a/dot_path.tmpl +++ b/dot_path.tmpl @@ -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" diff --git a/dot_zshrc.tmpl b/dot_zshrc.tmpl index 945b9a2..4b07b48 100644 --- a/dot_zshrc.tmpl +++ b/dot_zshrc.tmpl @@ -1,105 +1,4 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH - -# Path to your oh-my-zsh installation. -#export ZSH="$HOME/.oh-my-zsh" - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -#ZSH_THEME="robbyrussell" - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in $ZSH/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment one of the following lines to change the auto-update behavior -# zstyle ':omz:update' mode disabled # disable automatic updates -# zstyle ':omz:update' mode auto # update automatically without asking -# zstyle ':omz:update' mode reminder # just remind me to update when it's time - -# Uncomment the following line to change how often to auto-update (in days). -# zstyle ':omz:update' frequency 13 - -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS="true" - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# You can also set it to another string to have that shown instead of the default red dots. -# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" -# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? -# Standard plugins can be found in $ZSH/plugins/ -# Custom plugins may be added to $ZSH_CUSTOM/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -#plugins=(git) - -#source $ZSH/oh-my-zsh.sh - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - +# Enable oh-my-zsh, SEE: https://github.com/ohmyzsh/ohmyzsh export ZSH="$HOME/.oh-my-zsh" ZSH_THEME=powerlevel10k/powerlevel10k plugins=( @@ -113,12 +12,15 @@ plugins=( ) source "$ZSH/oh-my-zsh.sh" source "$HOME/.p10k.zsh" - -# Enable Powerlevel10k instant prompt if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi +# Enable asdf, SEE: https://github.com/asdf-vm/asdf +source "$HOME/.asdf/asdf.sh" +source "$HOME/.asdf/completions/asdf.bash" + +# Load dotfiles eval $(source "$HOME/.local/bin/detect-operating-system.sh") for file in $HOME/.{path,exports,functions,aliases,extra,$SYSTEM_DIST,custom}; do [ -f "$file" ] && source "$file" diff --git a/project.code-workspace b/project.code-workspace index 7d88b57..3175eea 100644 --- a/project.code-workspace +++ b/project.code-workspace @@ -26,7 +26,8 @@ "dot_screenrc": "properties", "dot_ubuntu": "shellscript", "dot_wgetrc": "properties", - "dot_zshrc.tmpl": "shellscript" + "dot_zshrc.tmpl": "shellscript", + "run_onchange_setup.sh.tmpl": "shellscript" } } } diff --git a/run_onchange_setup.sh.tmpl b/run_onchange_setup.sh.tmpl index df7d59c..cde9aa1 100644 --- a/run_onchange_setup.sh.tmpl +++ b/run_onchange_setup.sh.tmpl @@ -2,8 +2,30 @@ set -e -mkdir -p $HOME/{.aws,.azure,.cache,.config,.docker,.gnupg,.kube,.local,.ssh,bin,Projects} -chmod 700 $HOME/{.aws,.azure,.cache,.config,.docker,.gnupg,.kube,.local,.ssh,bin,Projects} +mkdir -p \ + $HOME/.aws \ + $HOME/.azure \ + $HOME/.cache \ + $HOME/.config \ + $HOME/.docker \ + $HOME/.gnupg \ + $HOME/.kube \ + $HOME/.local \ + $HOME/.ssh \ + $HOME/bin \ + $HOME/Projects +chmod 700 \ + $HOME/.aws \ + $HOME/.azure \ + $HOME/.cache \ + $HOME/.config \ + $HOME/.docker \ + $HOME/.gnupg \ + $HOME/.kube \ + $HOME/.local \ + $HOME/.ssh \ + $HOME/bin \ + $HOME/Projects eval $(source "$HOME/.local/bin/detect-operating-system.sh") source "$HOME/.path"