Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ jobs:

- name: Install shfmt
run: |
curl -fsSL https://github.com/mvdan/sh/releases/latest/download/shfmt_linux_amd64 \
-o /usr/local/bin/shfmt
chmod +x /usr/local/bin/shfmt
go install mvdan.cc/sh/v3/cmd/shfmt@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"

- name: Check formatting (shfmt)
run: shfmt -d setup/*.sh setup/install/*.sh
Expand Down
17 changes: 9 additions & 8 deletions setup/homeshick.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Install homeshick and clone dotfiles
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/lib.sh"

REPOS="$HOME/.homesick/repos"
Expand All @@ -11,17 +12,17 @@ github_clone "goude/homeshick" "$REPOS/homeshick"
source "$REPOS/homeshick/homeshick.sh"

HOMESHICK_REPOS=(
"goude/dotfiles"
"goude/dotfiles"
)

for repo in "${HOMESHICK_REPOS[@]}"; do
if [ -d "$REPOS/$(basename "$repo")" ]; then
ok "$repo already cloned"
else
info "Cloning $repo..."
homeshick --force --batch clone "$repo"
ok "$repo cloned"
fi
if [ -d "$REPOS/$(basename "$repo")" ]; then
ok "$repo already cloned"
else
info "Cloning $repo..."
homeshick --force --batch clone "$repo"
ok "$repo cloned"
fi
done

info "Linking dotfiles..."
Expand Down
1 change: 0 additions & 1 deletion setup/install-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ set -e
sudo apt update
sudo apt install ansible
ansible-playbook -k base.yml

2 changes: 1 addition & 1 deletion setup/install/binary-tools-install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#FIXME: the intent is that we want the latest version of starship, and the latest stable versions of shfmt and rust-analyzer
#!/usr/bin/env bash
#FIXME: the intent is that we want the latest version of starship, and the latest stable versions of shfmt and rust-analyzer
set -e

echo "Installing starship..."
Expand Down
7 changes: 4 additions & 3 deletions setup/install/homeshick-install.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#FIXME:it would be great if this could also support cloning the git@ ssh version also, if such access is available. otherwise clone the https version
#!/usr/bin/env bash
#FIXME:it would be great if this could also support cloning the git@ ssh version also, if such access is available. otherwise clone the https version

REPOS=$HOME/.homesick/repos
git clone https://github.com/goude/homeshick.git "$REPOS/homeshick"
# shellcheck disable=SC1091
source "$REPOS/homeshick/homeshick.sh"

echo "Cloning homeshick repos..."

homeshick_repos=(
"goude/dotfiles"
"goude/dotfiles"
)

for i in "${homeshick_repos[@]}"; do
homeshick --force --batch clone "$i"
homeshick --force --batch clone "$i"
done

echo "Silently and forcefully linking homeshick..."
Expand Down
3 changes: 2 additions & 1 deletion setup/install/node-packages-update.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#FIXME: some of these have been useful to have for neovim etc - now using mostly lazyvim so see what is needed and what can be left out
#!/bin/bash
#FIXME: some of these have been useful to have for neovim etc - now using mostly lazyvim so see what is needed and what can be left out
# shellcheck disable=SC1091
source "$HOME/.nvm/nvm.sh"
nvm use node

Expand Down
4 changes: 2 additions & 2 deletions setup/install/nvim-install.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#FIXME: intent here is to get the latest stable version - would be great if it could work for both standard docker container,running on bare metal linux, and rpi 500 and also macos
#!/usr/bin/env bash
#FIXME: intent here is to get the latest stable version - would be great if it could work for both standard docker container,running on bare metal linux, and rpi 500 and also macos
set -e

mkdir -p ~/.nvim/
rm -rf ~/.nvim/nvim-linux64
cd ~/.nvim/
cd ~/.nvim/ || exit 1

#wget https://github.com/neovim/neovim/releases/download/v0.10.2/nvim-linux64.tar.gz
wget https://github.com/neovim/neovim/releases/download/v0.11.4/nvim-linux-arm64.tar.gz
Expand Down
3 changes: 2 additions & 1 deletion setup/install/nvm-install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#FIXME: here we want a stable solution-it should get a good stable version needn't be the latest of node, so 22 for now is fine make configurable
#!/usr/bin/env bash
#FIXME: here we want a stable solution-it should get a good stable version needn't be the latest of node, so 22 for now is fine make configurable
# change to clone repo instead, see instructions at
# https://github.com/creationix/nvm/blob/master/README.markdown#install-script
#curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

export NVM_DIR="$HOME/.nvm"
# shellcheck disable=SC1091
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

nvm install 22
99 changes: 52 additions & 47 deletions setup/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,41 @@ set -euo pipefail
# -- Platform detection --

detect_os() {
case "$(uname -s)" in
Darwin) echo "macos" ;;
Linux)
if grep -qi microsoft /proc/version 2>/dev/null; then
echo "wsl"
else
echo "linux"
fi
;;
*) echo "unknown" ;;
esac
case "$(uname -s)" in
Darwin) echo "macos" ;;
Linux)
if grep -qi microsoft /proc/version 2>/dev/null; then
echo "wsl"
else
echo "linux"
fi
;;
*) echo "unknown" ;;
esac
}

detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "x86_64" ;;
aarch64|arm64) echo "aarch64" ;;
*) echo "$(uname -m)" ;;
esac
case "$(uname -m)" in
x86_64 | amd64) echo "x86_64" ;;
aarch64 | arm64) echo "aarch64" ;;
*) uname -m ;;
esac
}

# shellcheck disable=SC2034
OS="$(detect_os)"
# shellcheck disable=SC2034
ARCH="$(detect_arch)"

# -- Output helpers --

info() { printf ' \033[1;34m→\033[0m %s\n' "$*"; }
ok() { printf ' \033[1;32m✓\033[0m %s\n' "$*"; }
warn() { printf ' \033[1;33m!\033[0m %s\n' "$*" >&2; }
fail() { printf ' \033[1;31m✗\033[0m %s\n' "$*" >&2; exit 1; }
info() { printf ' \033[1;34m→\033[0m %s\n' "$*"; }
ok() { printf ' \033[1;32m✓\033[0m %s\n' "$*"; }
warn() { printf ' \033[1;33m!\033[0m %s\n' "$*" >&2; }
fail() {
printf ' \033[1;31m✗\033[0m %s\n' "$*" >&2
exit 1
}

# -- Idempotent helpers --

Expand All @@ -44,40 +49,40 @@ ensure_dir() { [ -d "$1" ] || mkdir -p "$1"; }

# Ensure ~/bin exists and is on PATH
ensure_bin_dir() {
ensure_dir "$HOME/bin"
case ":$PATH:" in
*":$HOME/bin:"*) ;;
*) export PATH="$HOME/bin:$PATH" ;;
esac
ensure_dir "$HOME/bin"
case ":$PATH:" in
*":$HOME/bin:"*) ;;
*) export PATH="$HOME/bin:$PATH" ;;
esac
}

# Download a file only if the command isn't already available
# Usage: install_binary <cmd_name> <url> [dest]
install_binary() {
local cmd="$1" url="$2" dest="${3:-$HOME/bin/$1}"
if has_cmd "$cmd"; then
ok "$cmd already installed"
return 0
fi
info "Installing $cmd..."
curl -fsSL "$url" -o "$dest"
chmod +x "$dest"
ok "$cmd installed"
local cmd="$1" url="$2" dest="${3:-$HOME/bin/$1}"
if has_cmd "$cmd"; then
ok "$cmd already installed"
return 0
fi
info "Installing $cmd..."
curl -fsSL "$url" -o "$dest"
chmod +x "$dest"
ok "$cmd installed"
}

# Git clone helper: prefers SSH if available, falls back to HTTPS
github_clone() {
local repo="$1" dest="$2"
if [ -d "$dest" ]; then
ok "$repo already cloned"
return 0
fi
if ssh -T git@github.com 2>&1 | grep -q "successfully authenticated"; then
info "Cloning $repo via SSH..."
git clone "git@github.com:${repo}.git" "$dest"
else
info "Cloning $repo via HTTPS..."
git clone "https://github.com/${repo}.git" "$dest"
fi
ok "$repo cloned"
local repo="$1" dest="$2"
if [ -d "$dest" ]; then
ok "$repo already cloned"
return 0
fi
if ssh -T git@github.com 2>&1 | grep -q "successfully authenticated"; then
info "Cloning $repo via SSH..."
git clone "git@github.com:${repo}.git" "$dest"
else
info "Cloning $repo via HTTPS..."
git clone "https://github.com/${repo}.git" "$dest"
fi
ok "$repo cloned"
}
63 changes: 32 additions & 31 deletions setup/neovim.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
#!/usr/bin/env bash
# Install latest stable Neovim
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/lib.sh"

ensure_bin_dir

install_neovim_brew() {
info "Installing Neovim via brew..."
brew install neovim
ok "Neovim installed via brew"
info "Installing Neovim via brew..."
brew install neovim
ok "Neovim installed via brew"
}

install_neovim_binary() {
local nvim_dir="$HOME/.nvim"
local tag tarball suffix

# Determine the right binary for this platform
case "$ARCH" in
x86_64) suffix="linux-x86_64" ;;
aarch64) suffix="linux-arm64" ;;
*) fail "Unsupported architecture for Neovim: $ARCH" ;;
esac

# Fetch latest stable tag
tag="$(curl -fsSL https://api.github.com/repos/neovim/neovim/releases/latest | grep '"tag_name"' | head -1 | cut -d'"' -f4)"
tarball="nvim-${suffix}.tar.gz"

info "Installing Neovim $tag ($suffix)..."
ensure_dir "$nvim_dir"
cd "$nvim_dir"

curl -fsSLO "https://github.com/neovim/neovim/releases/download/${tag}/${tarball}"
rm -rf "nvim-${suffix}"
tar xzf "$tarball"
rm "$tarball"

ln -sf "$nvim_dir/nvim-${suffix}/bin/nvim" "$HOME/bin/nvim"
ok "Neovim $tag installed"
local nvim_dir="$HOME/.nvim"
local tag tarball suffix

# Determine the right binary for this platform
case "$ARCH" in
x86_64) suffix="linux-x86_64" ;;
aarch64) suffix="linux-arm64" ;;
*) fail "Unsupported architecture for Neovim: $ARCH" ;;
esac

# Fetch latest stable tag
tag="$(curl -fsSL https://api.github.com/repos/neovim/neovim/releases/latest | grep '"tag_name"' | head -1 | cut -d'"' -f4)"
tarball="nvim-${suffix}.tar.gz"

info "Installing Neovim $tag ($suffix)..."
ensure_dir "$nvim_dir"
cd "$nvim_dir" || exit 1

curl -fsSLO "https://github.com/neovim/neovim/releases/download/${tag}/${tarball}"
rm -rf "nvim-${suffix}"
tar xzf "$tarball"
rm "$tarball"

ln -sf "$nvim_dir/nvim-${suffix}/bin/nvim" "$HOME/bin/nvim"
ok "Neovim $tag installed"
}

case "$OS" in
macos) install_neovim_brew ;;
linux|wsl) install_neovim_binary ;;
*) fail "Unsupported OS: $OS" ;;
macos) install_neovim_brew ;;
linux | wsl) install_neovim_binary ;;
*) fail "Unsupported OS: $OS" ;;
esac
9 changes: 5 additions & 4 deletions setup/node.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Install nvm and Node.js
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/lib.sh"

NODE_VERSION="${NODE_VERSION:-22}"
Expand All @@ -9,11 +10,11 @@ NVM_VERSION="${NVM_VERSION:-0.40.3}"
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"

if [ -s "$NVM_DIR/nvm.sh" ]; then
ok "nvm already installed"
ok "nvm already installed"
else
info "Installing nvm $NVM_VERSION..."
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh" | bash
ok "nvm installed"
info "Installing nvm $NVM_VERSION..."
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh" | bash
ok "nvm installed"
fi

# shellcheck disable=SC1091
Expand Down
Loading
Loading