diff --git a/zsh/.config/zsh/.gitignore b/zsh/.config/zsh/.gitignore index dffc945..0e7ebe1 100644 --- a/zsh/.config/zsh/.gitignore +++ b/zsh/.config/zsh/.gitignore @@ -2,3 +2,4 @@ .zsh_history .zcompcache/ .zsh_sessions/ +config/secrets.zsh diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index a23e27e..e18e459 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,5 +1,8 @@ # install zinit -source $ZDOTDIR/zinit.zsh +if ! source "$ZDOTDIR/zinit.zsh"; then + print -u2 "zinit: failed to initialize; skipping plugin configuration" + return 1 +fi zinit light zdharma-continuum/zinit-annex-bin-gem-node zinit light zdharma-continuum/zinit-annex-binary-symlink diff --git a/zsh/.config/zsh/config/bin.zsh b/zsh/.config/zsh/config/bin.zsh index 6c098e5..6282424 100644 --- a/zsh/.config/zsh/config/bin.zsh +++ b/zsh/.config/zsh/config/bin.zsh @@ -1,9 +1,11 @@ #!/usr/bin/env zsh -# Define a marker file (choose a location in your cache or temp directory) -MARKER_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/gnu_tools_symlinked" +local brew_prefix="${HOMEBREW_PREFIX:-}" +if [[ -z "$brew_prefix" ]] && command -v brew >/dev/null 2>&1; then + brew_prefix="$(brew --prefix 2>/dev/null)" +fi -if [[ ! -f "$MARKER_FILE" ]]; then +if [[ -n "$brew_prefix" ]]; then gnu_tools=( "coreutils" "findutils" @@ -14,23 +16,22 @@ if [[ ! -f "$MARKER_FILE" ]]; then "grep" ) - for tool in $gnu_tools; do - gnubin="/opt/homebrew/opt/$tool/libexec/gnubin" - if [[ -d "$gnubin" ]]; then - for bin in "$gnubin"/*(N); do - ln -sf "$bin" "$XDG_BIN_HOME/$(basename "$bin")" - done - fi - done - - # Create the marker file to indicate the script has run - touch "$MARKER_FILE" + if mkdir -p "$XDG_BIN_HOME"; then + for tool in $gnu_tools; do + gnubin="$brew_prefix/opt/$tool/libexec/gnubin" + if [[ -d "$gnubin" ]]; then + for bin in "$gnubin"/*(N); do + target="$XDG_BIN_HOME/${bin:t}" + [[ "$target" -ef "$bin" ]] || ln -sf "$bin" "$target" + done + fi + done + fi fi - local bin_paths=( "$XDG_BIN_HOME" - "/opt/homebrew/opt/gnu-getopt/bin" + "${brew_prefix:+$brew_prefix/opt/gnu-getopt/bin}" ) for bin_path in "${bin_paths[@]}"; do if [[ -d "$bin_path" ]]; then diff --git a/zsh/.config/zsh/config/default.zsh b/zsh/.config/zsh/config/default.zsh index d599410..fe249f6 100644 --- a/zsh/.config/zsh/config/default.zsh +++ b/zsh/.config/zsh/config/default.zsh @@ -8,9 +8,13 @@ export VISUAL="micro" export SUDO_EDITOR="micro" export STARSHIP_CONFIG="$XDG_CONFIG_HOME"/starship/starship.toml +export OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true export PNPM_HOME="$HOME/.local/share/pnpm" -case ":$PATH:" in - *":$PNPM_HOME/bin:"*) ;; - *) path=("$PNPM_HOME/bin" $path) ;; -esac + +typeset -U path +path=( + "$HOME/.opencode/bin" + "$PNPM_HOME/bin" + $path +) diff --git a/zsh/.config/zsh/zinit.zsh b/zsh/.config/zsh/zinit.zsh index c0ce594..efdf9f9 100644 --- a/zsh/.config/zsh/zinit.zsh +++ b/zsh/.config/zsh/zinit.zsh @@ -1,8 +1,15 @@ #!/usr/bin/env zsh ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" -[[ ! -d "$ZINIT_HOME" ]] && mkdir -p "$(dirname "$ZINIT_HOME")" -[[ ! -d "$ZINIT_HOME/.git" ]] && git clone --depth 1 https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +if [[ ! -d "$ZINIT_HOME/.git" ]]; then + mkdir -p "$(dirname "$ZINIT_HOME")" || return 1 + git clone --depth 1 https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" || return 1 +fi + +if [[ ! -r "$ZINIT_HOME/zinit.zsh" ]]; then + print -u2 "zinit: bootstrap is incomplete at $ZINIT_HOME" + return 1 +fi # not to use aliases: zi or zini typeset -A ZINIT diff --git a/zsh/.zshenv b/zsh/.zshenv index b8aa3ec..ee92690 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,3 +1,7 @@ -XDG_CONFIG_HOME="${HOME}/.config" -XDG_BIN_HOME="${HOME}/.local/bin" -ZDOTDIR="${XDG_CONFIG_HOME}/zsh" +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" +export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" +export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}" + +XDG_BIN_HOME="${XDG_BIN_HOME:-$HOME/.local/bin}" +ZDOTDIR="$XDG_CONFIG_HOME/zsh"