diff --git a/Commands/Bin/mod.just b/Commands/Bin/mod.just index c83e74a..db54dd8 100644 --- a/Commands/Bin/mod.just +++ b/Commands/Bin/mod.just @@ -1,6 +1,19 @@ project_root := justfile_directory() bin_script_dir := project_root + "/Scripts/bin" +# List the repo-managed binary names, or available releases for one tool. +[default] +list tool='': + if [ -n '{{tool}}' ]; then \ + bash '{{bin_script_dir}}/update.sh' --list '{{tool}}'; \ + else \ + jq -r 'keys[]' '{{project_root}}/Bins/versions.json'; \ + fi + +# List available releases for a supported binary. +releases tool: + bash '{{bin_script_dir}}/update.sh' --list '{{tool}}' + # Install all pinned repo-managed binaries into ~/.local/bin. install-all: bash '{{bin_script_dir}}/install.sh' --all @@ -13,10 +26,6 @@ install tool: update tool version='': bash '{{bin_script_dir}}/update.sh' '{{tool}}' '{{version}}' -# List available releases for a supported binary. -list tool: - bash '{{bin_script_dir}}/update.sh' --list '{{tool}}' - # Print the currently pinned versions. show: cat '{{project_root}}/Bins/versions.json' diff --git a/Commands/Git/mod.just b/Commands/Git/mod.just new file mode 100644 index 0000000..02672da --- /dev/null +++ b/Commands/Git/mod.just @@ -0,0 +1,11 @@ +project_root := justfile_directory() +scripts_dir := project_root + "/Scripts" + +# Print the active global Git configuration. +[default] +show: + bash '{{scripts_dir}}/git.sh' show + +# Set the global Git editor. Defaults to VS Code; pass `nvim` for Neovim. +editor value='code': + bash '{{scripts_dir}}/git.sh' editor '{{value}}' diff --git a/Commands/Lang/mod.just b/Commands/Lang/mod.just index abbac8e..57e2db9 100644 --- a/Commands/Lang/mod.just +++ b/Commands/Lang/mod.just @@ -1,20 +1,29 @@ project_root := justfile_directory() scripts_dir := project_root + "/Scripts" +# Install every language toolchain in full-setup order. +all: node go rust python r cpp + +# Install Node.js, pnpm, Yarn, and Bun tooling. node: bash '{{scripts_dir}}/node.sh' +# Install Go and GVM tooling. go: bash '{{scripts_dir}}/go.sh' +# Install the Rust toolchain. rust: bash '{{scripts_dir}}/rust.sh' +# Install Python, pyenv, and Miniforge tooling. python: bash '{{scripts_dir}}/python.sh' +# Install R tooling. r: bash '{{scripts_dir}}/r.sh' +# Install the C and C++ toolchain. cpp: bash '{{scripts_dir}}/cpp.sh' diff --git a/Commands/Setup/mod.just b/Commands/Setup/mod.just index d35696b..9722851 100644 --- a/Commands/Setup/mod.just +++ b/Commands/Setup/mod.just @@ -2,9 +2,14 @@ project_root := justfile_directory() scripts_dir := project_root + "/Scripts" # Run the full setup flow. +[default] all: bash '{{scripts_dir}}/setup.sh' +# Run the lightweight bootstrap flow: base packages and shell-file stow. +bootstrap: + bash '{{scripts_dir}}/setup.sh' --bootstrap-only + # Install the base system layer only. base: bash '{{scripts_dir}}/base.sh' diff --git a/Justfile b/Justfile index f054438..0ea6899 100644 --- a/Justfile +++ b/Justfile @@ -1,59 +1,10 @@ set shell := ["bash", "-cu"] -project_root := justfile_directory() -scripts_dir := project_root + "/Scripts" -bin_script_dir := scripts_dir + "/bin" +mod bin "Commands/Bin" +mod git "Commands/Git" +mod lang "Commands/Lang" +mod setup "Commands/Setup" +[default] help: - @printf '%s\n' \ - 'Dot-Zsh commands:' \ - '' \ - ' just setup all # full setup flow' \ - ' just setup base # base layer only' \ - ' just setup stow # stow Zsh files into $HOME' \ - ' just setup clean # remove stowed Zsh files from $HOME' \ - ' just setup update # git pull + full setup' \ - '' \ - ' just lang node # install Node tooling' \ - ' just lang go # install Go tooling' \ - ' just lang rust # install Rust tooling' \ - ' just lang python # install Python tooling' \ - ' just lang r # install R tooling' \ - ' just lang cpp # install C/C++ tooling' \ - '' \ - ' just bin install-all # install all pinned binaries' \ - ' just bin install nvim # install one pinned binary' \ - ' just bin update nvim # update pinned version for a binary' \ - ' just bin list nvim # list available releases' \ - ' just bin show # print current pinned versions' - -setup action='all': - case '{{action}}' in \ - all) bash '{{scripts_dir}}/setup.sh' ;; \ - base) bash '{{scripts_dir}}/base.sh' ;; \ - stow) bash '{{scripts_dir}}/setup.sh' --stow-only ;; \ - clean) stow --dir='{{project_root}}' -D Zsh --target="$HOME" ;; \ - update) git -C '{{project_root}}' pull origin main && just --justfile '{{project_root}}/Justfile' setup all ;; \ - *) printf 'Unknown setup action: %s\n' '{{action}}' >&2; exit 1 ;; \ - esac - -lang tool: - case '{{tool}}' in \ - node) bash '{{scripts_dir}}/node.sh' ;; \ - go) bash '{{scripts_dir}}/go.sh' ;; \ - rust) bash '{{scripts_dir}}/rust.sh' ;; \ - python) bash '{{scripts_dir}}/python.sh' ;; \ - r) bash '{{scripts_dir}}/r.sh' ;; \ - cpp) bash '{{scripts_dir}}/cpp.sh' ;; \ - *) printf 'Unknown language target: %s\n' '{{tool}}' >&2; exit 1 ;; \ - esac - -bin action='show' tool='' version='': - case '{{action}}' in \ - install-all) bash '{{bin_script_dir}}/install.sh' --all ;; \ - install) [ -n '{{tool}}' ] || { printf 'bin install requires a tool name\n' >&2; exit 1; }; bash '{{bin_script_dir}}/install.sh' '{{tool}}' ;; \ - update) [ -n '{{tool}}' ] || { printf 'bin update requires a tool name\n' >&2; exit 1; }; bash '{{bin_script_dir}}/update.sh' '{{tool}}' '{{version}}' ;; \ - list) [ -n '{{tool}}' ] || { printf 'bin list requires a tool name\n' >&2; exit 1; }; bash '{{bin_script_dir}}/update.sh' --list '{{tool}}' ;; \ - show) cat '{{project_root}}/Bins/versions.json' ;; \ - *) printf 'Unknown bin action: %s\n' '{{action}}' >&2; exit 1 ;; \ - esac + just --list --list-submodules diff --git a/README.md b/README.md index 6d5ab2c..80744fe 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Modular `just` commands. - `Commands/Setup/mod.just` - `Commands/Lang/mod.just` - `Commands/Bin/mod.just` +- `Commands/Git/mod.just` #### `Bins/` @@ -104,10 +105,15 @@ This runs the full flow in `Scripts/setup.sh`: ```bash just setup base +just setup bootstrap just setup stow just setup clean just setup update +just git show +just git editor +just git editor nvim + just lang node just lang go just lang rust @@ -116,14 +122,21 @@ just lang r just lang cpp just bin show +just bin list just bin install-all just bin install nvim -just bin list nvim +just bin releases nvim +just bin list nvim # backwards-compatible shorthand for releases just bin update nvim + +just lang all ``` If `fzf` is available, `just bin update ` can use interactive selection. +`just setup all` and `just setup base` now set the default global Git editor to VS Code (`code --wait`). +If you want to switch to Neovim later, run `just git editor nvim`. + --- ## Secrets model diff --git a/Scripts/base.sh b/Scripts/base.sh index ec34836..5f123a3 100644 --- a/Scripts/base.sh +++ b/Scripts/base.sh @@ -402,6 +402,8 @@ else ensure_git_credential_helper 'cache --timeout=43200' fi +git config --global core.editor "code --wait" + # 6. Cleanup & Secrets rm -f "$HOME/.zshrc" "$HOME/.zsh_aliases" mkdir -p "$REPO_ROOT/Zsh" diff --git a/Scripts/git.sh b/Scripts/git.sh new file mode 100644 index 0000000..5ebd013 --- /dev/null +++ b/Scripts/git.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -euo pipefail + +usage() { + cat <<'EOF' +Usage: + git.sh show + git.sh editor [code|nvim] +EOF +} + +set_editor() { + local editor_name="${1:-code}" + + case "$editor_name" in + code) + git config --global core.editor "code --wait" + printf 'Set git core.editor to: %s\n' 'code --wait' + ;; + nvim) + git config --global core.editor "nvim" + printf 'Set git core.editor to: %s\n' 'nvim' + ;; + *) + printf 'Unknown editor: %s\n' "$editor_name" >&2 + usage >&2 + exit 1 + ;; + esac +} + +show_config() { + local name email editor + local helpers=() + local helper + + name="$(git config --global --get user.name || true)" + email="$(git config --global --get user.email || true)" + editor="$(git config --global --get core.editor || true)" + + while IFS= read -r helper; do + [ -n "$helper" ] && helpers+=("$helper") + done < <(git config --global --get-all credential.helper || true) + + printf 'Global git config\n' + printf ' user.name %s\n' "${name:-}" + printf ' user.email %s\n' "${email:-}" + printf ' core.editor %s\n' "${editor:-}" + + if [ "${#helpers[@]}" -eq 0 ]; then + printf ' credential.helper %s\n' '' + else + printf ' credential.helper %s\n' "${helpers[0]}" + if [ "${#helpers[@]}" -gt 1 ]; then + local index + for (( index=1; index<${#helpers[@]}; index++ )); do + printf ' %s\n' "${helpers[$index]}" + done + fi + fi +} + +case "${1:-show}" in + show) + show_config + ;; + editor) + set_editor "${2:-code}" + ;; + *) + usage >&2 + exit 1 + ;; +esac diff --git a/Zsh/.zshenv b/Zsh/.zshenv index 25e0c59..fb90f1b 100644 --- a/Zsh/.zshenv +++ b/Zsh/.zshenv @@ -18,6 +18,7 @@ fi export PATH="$HOME/.opencode/bin:$PATH" export OPENCHAMBER_HOST="${OPENCHAMBER_HOST:-0.0.0.0}" export VAULT_ADDR="${VAULT_ADDR:-http://192.168.30.53:8200}" +export PLANNOTATOR_REMOTE="${PLANNOTATOR_REMOTE:-1}" export PLANNOTATOR_PORT="${PLANNOTATOR_PORT:-9999}" # Derived environment variables that may depend on machine-local secrets. @@ -27,3 +28,6 @@ export PLANNOTATOR_PORT="${PLANNOTATOR_PORT:-9999}" [ -n "${AZURE_OPENAI_API_KEY:-}" ] && export FOUNDRY_ANTHROPIC_API_KEY="$AZURE_OPENAI_API_KEY" [ -n "${AZURE_OPENAI_API_KEY:-}" ] && export CHROMA_OPENAI_API_KEY="$AZURE_OPENAI_API_KEY" [ -n "${OUTLINE_MOKU_TOKEN:-}" ] && export OUTLINE_MOKU_AUTHORIZATION="Bearer $OUTLINE_MOKU_TOKEN" + +# bun completions +[ -s "/home/mangopig/.programming/node/bun/_bun" ] && source "/home/mangopig/.programming/node/bun/_bun" diff --git a/Zsh/.zshrc b/Zsh/.zshrc index 9d8c817..0c99baa 100644 --- a/Zsh/.zshrc +++ b/Zsh/.zshrc @@ -213,12 +213,30 @@ fi export HISTORY_SUBSTRING_SEARCH_PREFIXED=1 +zmodload zsh/terminfo 2>/dev/null || true + +dotzsh_bind_if_present() { + local sequence="$1" + local widget="$2" + + [ -n "$sequence" ] || return 0 + bindkey "$sequence" "$widget" +} + # History keybindings bindkey '^[[A' history-substring-search-up bindkey '^[OA' history-substring-search-up bindkey '^[[B' history-substring-search-down bindkey '^[OB' history-substring-search-down +# Word movement keybindings +dotzsh_bind_if_present "${terminfo[kLFT5]:-}" backward-word +dotzsh_bind_if_present "${terminfo[kRIT5]:-}" forward-word +bindkey '^[[1;5D' backward-word +bindkey '^[[1;5C' forward-word +bindkey '^[[5D' backward-word +bindkey '^[[5C' forward-word + # bun export BUN_INSTALL="$PROG_DIR/node/bun" case ":$PATH:" in @@ -233,3 +251,6 @@ case ":$PATH:" in *) export PATH="$PNPM_HOME:$PATH" ;; esac # pnpm end + +# Allow Comments +setopt INTERACTIVE_COMMENTS \ No newline at end of file