diff --git a/README.md b/README.md
index 02dbe53..ebfde60 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
[](https://github.com/andrejusk/dotfiles/actions/workflows/ci.yml)
-My collection of dotfiles and install scripts
-to set up development environments
+A collection of dotfiles and install scripts
+to set up my development environment
🛠️ 📂️ 🚀
## Usage
@@ -12,16 +12,6 @@ A local repository can be installed by running:
./script/install
-
-
-Environment configuration for install script
-
-
-| Variable | Description |
-| --- | --- |
-| `LOG_TARGET` | File to log installation output to (default: `~/.dotfiles/logs/install-{date}.log`) |
-
-
### Automated setup
This repository can be installed without a local copy
@@ -32,18 +22,3 @@ by invoking the `setup` script directly via `curl`:
# Run
curl -s https://raw.githubusercontent.com/andrejusk/dotfiles/HEAD/script/setup | bash
-
-
-
-
-Environment configuration for setup script
-
-
-| Variable | Description |
-| --- | --- |
-| `DOTFILES_DIR` | Directory to clone the repository into (default: `~/.dotfiles`)
-| `DOTFILES_SKIP_INSTALL` | Skip running the install script (default: `false`)
-| `GITHUB_AUTHOR` | GitHub username to use for cloning repositories (default: `andrejusk`) |
-| `GITHUB_REPO` | GitHub repository name to clone (default: `dotfiles`)
-| `GITHUB_BRANCH` | GitHub branch to clone (default: `master`)
-
diff --git a/home/.zshrc b/home/.zshrc
index 9a3721f..cc8be21 100644
--- a/home/.zshrc
+++ b/home/.zshrc
@@ -18,6 +18,7 @@ plugins=(
emoji
git
history
+ poetry
zsh-autosuggestions
zsh-syntax-highlighting
)
@@ -25,3 +26,7 @@ source $ZSH/oh-my-zsh.sh
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
+
+export NVM_DIR="$HOME/.nvm"
+[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
+[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
diff --git a/script/install b/script/install
index 5322e51..6e254a4 100755
--- a/script/install
+++ b/script/install
@@ -5,17 +5,21 @@ set -eo pipefail
# Script to run all install scripts contained in install.d
#
-# Prevent running as root and check sudo access
+# Prevent running as root
if [[ $EUID -eq 0 ]]; then
echo "Failed: Running as sudo. Please run as user"
exit 1
fi
+
+# Ensure sudo credentials are cached
sudo -v
+# Set up directory variables
dir=$(dirname "$0")
install_dir="$dir/install.d"
export DOTFILES=$(dirname "$dir")
+# Set up log destination
if [[ -z "$LOG_TARGET" ]]; then
timestamp=$(date +%Y-%m-%dT%H:%M:%S)
uuid=$(
@@ -29,7 +33,14 @@ if [[ -z "$LOG_TARGET" ]]; then
else
log_target="$LOG_TARGET"
fi
+touch "$log_target"
+if [[ ! -f "$log_target" ]]; then
+ echo "Failed: Unable to create log file \"$log_target\""
+ exit 1
+fi
+log_abs_target=$(readlink -f "$log_target")
+# Run install scripts
install() {
echo "Running \"$(basename "$0")\" at \"$(date)\""
echo "Running as \"$(whoami)\" on \"$(hostname)\""
@@ -42,8 +53,9 @@ install() {
unset script_name
done
}
+echo "install: Logging to \"$log_abs_target\""
+install 2>&1 | tee "$log_abs_target"
-echo "install: Logging to \"$log_target\""
-install 2>&1 | tee "$log_target"
-
-unset uuid dir install_dir log_dir log_target
+# Clean up
+unset uuid dir install_dir log_dir log_abs_target log_target
+echo "Thank you!"
diff --git a/script/install.d/10-pyenv-pkglist b/script/install.d/10-pyenv-pkglist
deleted file mode 100644
index 6f13840..0000000
--- a/script/install.d/10-pyenv-pkglist
+++ /dev/null
@@ -1,15 +0,0 @@
-build-essential
-libssl-dev
-libbz2-dev
-libreadline-dev
-libsqlite3-dev
-libxml2-dev
-libxmlsec1-dev
-llvm
-libncurses5-dev
-libncursesw5-dev
-xz-utils
-tk-dev
-libffi-dev
-liblzma-dev
-zlib1g-dev
diff --git a/script/install.d/10-pyenv.sh b/script/install.d/10-pyenv.sh
index a457cc1..0ab4823 100644
--- a/script/install.d/10-pyenv.sh
+++ b/script/install.d/10-pyenv.sh
@@ -5,18 +5,35 @@
# Configure pyenv.
#
-if ! bin_in_path "pyenv"; then
+if ! command -v "pyenv" &> /dev/null; then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# see https://github.com/pyenv/pyenv/wiki/common-build-problems
- pyenv_list_file="$INSTALL_DIR/10-pyenv-pkglist"
- install_file "$pyenv_list_file"
+ ppyenv_packages=(
+ build-essential
+ libssl-dev
+ libbz2-dev
+ libreadline-dev
+ libsqlite3-dev
+ libxml2-dev
+ libxmlsec1-dev
+ llvm
+ libncurses5-dev
+ libncursesw5-dev
+ xz-utils
+ tk-dev
+ libffi-dev
+ liblzma-dev
+ zlib1g-dev
+ )
+ pyenv_packages=($(comm -13 <(printf "%s\n" "${pyenv_packages[@]}" | sort) <(dpkg --get-selections | awk '{print $1}' | sort)))
+ if [ ${#pyenv_packages[@]} -gt 0 ]; then
+ sudo apt-get install -qq "${pyenv_packages[@]}"
+ fi
# see https://github.com/pyenv/pyenv-installer
- download_run \
- "https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer" \
- bash
-e
- unset pyenv_list_file
+ bash -c "$(curl -fsSL https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer)"
+
+ unset pyenv_packages
elif [[ "$OSTYPE" == "darwin"* ]]; then
brew install pyenv
brew install pyenv-virtualenv
@@ -30,10 +47,9 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
https://github.com/pyenv/pyenv-virtualenv.git \
$virtualenv_path
fi
+ unset virtualenv_path
fi
eval "$(pyenv init --path)"
-pyenv update
-
pyenv --version
diff --git a/script/install.d/11-python.sh b/script/install.d/11-python.sh
index f10e650..938a5a2 100644
--- a/script/install.d/11-python.sh
+++ b/script/install.d/11-python.sh
@@ -7,16 +7,49 @@
export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
-if ! bin_in_path "pip3"; then
- pyenv install 3.9.0
- pyenv global 3.9.0
+if ! command -v "pip3" &>/dev/null; then
+ pyenv install 3.12.1
+ pyenv global 3.12.1
fi
-pip install --upgrade pip
-pip3 install --upgrade pip
+pip install --quiet --upgrade --user pip
+pip3 install --quiet --upgrade --user pip
python3 --version
pip3 --version
-for dep in $(jq -r ".pip_dependencies[]" $CONFIG); do
- pip3 install --upgrade $dep
-done
+pip_dependencies=(
+ # docker-compose
+ # neovim
+ # "python-language-server[all]"
+ # pyvim
+)
+installed_packages=$(pip3 list --format=freeze | awk -F'==' '{print $1}')
+pip_dependencies=($(comm -13 <(printf "%s\n" "${installed_packages[@]}" | sort) <(printf "%s\n" "${pip_dependencies[@]}" | sort)))
+
+if [ ${#pip_dependencies[@]} -gt 0 ]; then
+ pip3 install --quiet --upgrade --user "${pip_dependencies[@]}"
+fi
+
+unset installed_packages pip_dependencies PYTHON_KEYRING_BACKEND
+
+if ! command -v "pipx" &>/dev/null; then
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
+ sudo apt-get install -qq pipx
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
+ brew install pipx
+ fi
+fi
+
+echo "pipx $(pipx --version)"
+
+if ! command -v "poetry" &>/dev/null; then
+ pipx install poetry
+fi
+
+poetry --version
+
+POETRY_PLUGIN="$ZSH/custom/plugins/poetry"
+if [ ! -d "$POETRY_PLUGIN" ]; then
+ mkdir -p $POETRY_PLUGIN
+ poetry completions zsh > $POETRY_PLUGIN/_poetry
+fi
diff --git a/script/install.d/12-node.sh b/script/install.d/12-node.sh
index 0286127..61bf692 100644
--- a/script/install.d/12-node.sh
+++ b/script/install.d/12-node.sh
@@ -5,29 +5,35 @@
# Configure Node.js.
#
-nvm_version="0.39.7"
-if ! bin_in_path "nvm"; then
- download_run "https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh" \
- "bash"
-fi
-
NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
+nvm_version="0.39.7"
+if ! command -v "nvm" &>/dev/null; then
+ bash -c "$(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v${nvm_version}/install.sh)"
+ [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
+fi
+
nvm --version
nvm alias default lts/iron
nvm install lts/iron
nvm use lts/iron
-node --version
+echo "Node.js $(node --version)"
-yarn --version
+echo "npm $(npm --version)"
-if [[ "$OSTYPE" == "linux-gnu"* ]]; then
- for dep in $(jq -r ".node_dependencies[]" $CONFIG); do
- yarn global add $dep
- yarn global upgrade $dep
- done
+npm_dependencies=(
+ "firebase-tools"
+ "neovim"
+ "typescript-language-server"
+ "typescript"
+)
+
+npm_dependencies=($(comm -13 <(printf "%s\n" "${npm_dependencies[@]}" | sort) <(npm list -g --depth=0 --parseable | awk -F'/' '{print $NF}' | sort)))
+
+if [ ${#npm_dependencies[@]} -gt 0 ]; then
+ npm install -g "${npm_dependencies[@]}"
fi
-unset nvm_version
+unset nvm_version npm_dependencies
diff --git a/script/install.d/21-gh_cli.sh b/script/install.d/21-gh_cli.sh
index 642e86f..e9b2ab0 100644
--- a/script/install.d/21-gh_cli.sh
+++ b/script/install.d/21-gh_cli.sh
@@ -1,4 +1,4 @@
-# /bin/bash
+#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# Description:
diff --git a/script/install.d/25-terraform.sh b/script/install.d/25-terraform.sh
new file mode 100644
index 0000000..5640013
--- /dev/null
+++ b/script/install.d/25-terraform.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+
+# -----------------------------------------------------------------------------
+# Description:
+# Install terraform.
+#
+
+if ! command -v "terraform" &>/dev/null; then
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
+ sudo apt-get install -qq terraform
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
+ brew tap hashicorp/tap
+ brew install hashicorp/tap/terraform
+ fi
+fi
diff --git a/script/install.d/30-iterm2.sh b/script/install.d/30-iterm2.sh
index 93efee3..52d4c12 100644
--- a/script/install.d/30-iterm2.sh
+++ b/script/install.d/30-iterm2.sh
@@ -6,7 +6,7 @@
#
if [[ "$OSTYPE" == "darwin"* ]]; then
- if ! command -v iterm2 &> /dev/null; then
+ if ! brew list --cask iterm2 &>/dev/null; then
brew install --cask iterm2
fi
fi
diff --git a/script/install.d/80-neofetch.sh b/script/install.d/80-neofetch.sh
new file mode 100644
index 0000000..8c9662e
--- /dev/null
+++ b/script/install.d/80-neofetch.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+# -----------------------------------------------------------------------------
+# Description:
+# Install neofetch.
+#
+
+if ! command -v "neofetch" &>/dev/null; then
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
+ sudo apt-get install -qq neofetch
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
+ brew install neofetch
+ fi
+fi
diff --git a/script/install.d/99-screenfetch.sh b/script/install.d/99-screenfetch.sh
index 180fa04..912f0d1 100644
--- a/script/install.d/99-screenfetch.sh
+++ b/script/install.d/99-screenfetch.sh
@@ -5,4 +5,4 @@
# Print system information.
#
-screenfetch
+neofetch
diff --git a/script/install_config.json b/script/install_config.json
index 98311ea..2db25d7 100644
--- a/script/install_config.json
+++ b/script/install_config.json
@@ -69,19 +69,5 @@
"tmux",
"unzip",
"yarn"
- ],
- "node_dependencies": [
- "firebase-tools",
- "neovim",
- "typescript-language-server",
- "typescript"
- ],
- "pip_dependencies": [
- "awscli",
- "docker-compose",
- "neovim",
- "poetry",
- "python-language-server[all]",
- "pyvim"
]
}
diff --git a/tests/.python-version b/tests/.python-version
index a5c4c76..171a6a9 100644
--- a/tests/.python-version
+++ b/tests/.python-version
@@ -1 +1 @@
-3.9.0
+3.12.1