Skip to content

Cross-platform reliability fixes for shell configs and git aliases#2

Merged
dbmrq merged 9 commits into
masterfrom
copilot/cleanup-dotfiles-reliability-fixes
Feb 16, 2026
Merged

Cross-platform reliability fixes for shell configs and git aliases#2
dbmrq merged 9 commits into
masterfrom
copilot/cleanup-dotfiles-reliability-fixes

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 16, 2026

Dotfiles had hard-coded paths and GNU-specific flags that broke on Intel Macs and BSD systems. Fixed shell sourcing order to prevent modern CLI tools from being shadowed by base aliases.

Shell environment

Zsh/.zprofile: Guard Homebrew eval for both Apple Silicon and Intel paths:

if [[ -x /opt/homebrew/bin/brew ]]; then
    eval "$(/opt/homebrew/bin/brew shellenv)"
elif [[ -x /usr/local/bin/brew ]]; then
    eval "$(/usr/local/bin/brew shellenv)"
fi

Zsh/.zprofile, Zsh/.zshrc: Remove duplicate EDITOR/VISUAL exports. .shell_common already handles nvim detection correctly.

Zsh/.zshrc: Move .shell_common sourcing to line 45 (before Modern CLI Replacements). Base aliases must be set before eza/bat/fzf override them.

Cross-platform compatibility

Shell/.shell_common:

  • duh alias: Change --max-depth=1-d 1 (BSD du compatibility)
  • zipr: Convert from alias to function: zipr() { zip -r "$1.zip" "$1"; }

Git modernization

Git/.gitconfig-essential:

  • Push default: upstreamsimple
  • Discard alias: checkout --restore --

Bootstrap

Bootstrap/stow.sh: Skip Hammerspoon/ and TeX/ on non-Darwin systems to prevent stow errors.

README.md: Mark Zsh/ as "Both" platforms.

Original prompt

Here's a concise to-do list:


Dotfiles cleanup — cross-platform reliability fixes

  1. Zsh/.zprofile: Guard the Homebrew eval (line 41). Replace eval "$(/opt/homebrew/bin/brew shellenv)" with:

    if [[ -x /opt/homebrew/bin/brew ]]; then
        eval "$(/opt/homebrew/bin/brew shellenv)"
    elif [[ -x /usr/local/bin/brew ]]; then
        eval "$(/usr/local/bin/brew shellenv)"
    fi
  2. Zsh/.zprofile: Remove the EDITOR/VISUAL exports (lines 9–10). .shell_common already handles this correctly with nvim detection.

  3. Zsh/.zshrc: Remove the EDITOR/VISUAL exports (lines 15–16) for the same reason.

  4. Zsh/.zshrc: Move [[ -f "$HOME/.shell_common" ]] && source "$HOME/.shell_common" (line 326) to early in the file — right after the Environment/options section (around line 45), before the Modern CLI Replacements block. This way the base aliases from .shell_common are set first, then eza/bat/fzf override them correctly.

  5. Shell/.shell_common: Fix the duh alias (line 28). Replace --max-depth=1 with -d 1 (BSD du on macOS doesn't support --max-depth).

  6. Shell/.shell_common: Replace the zipr alias (line 22) with a function:

    zipr() { zip -r "$1.zip" "$1"; }
  7. Git/.gitconfig-essential: Change default = upstream to default = simple in the [push] section (line 53).

  8. Git/.gitconfig-essential: Change discard = checkout -- to discard = restore -- (line 39).

  9. Bootstrap/stow.sh: In get_packages(), add OS-aware skipping after the existing macOS/ skip (around line 58):

    if [[ "$(uname -s)" != "Darwin" ]]; then
        [[ "$dir" == "Hammerspoon/" ]] && continue
        [[ "$dir" == "TeX/" ]] && continue
    fi
  10. README.md: Update the structure table to mark Zsh/ as "Both" instead of "macOS".


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Guard Homebrew eval in .zprofile for both /opt/homebrew and /usr/local
- Remove duplicate EDITOR/VISUAL exports (handled by .shell_common)
- Move .shell_common sourcing early in .zshrc (before Modern CLI Replacements)
- Fix duh alias to use BSD-compatible -d flag instead of --max-depth
- Convert zipr alias to function for better functionality
- Change git push default to simple for better behavior
- Update git discard alias to use modern restore command
- Add OS-aware skipping in stow.sh for macOS-only directories
- Update README to mark Zsh as cross-platform (Both)

Co-authored-by: dbmrq <15813674+dbmrq@users.noreply.github.com>
Copilot AI changed the title [WIP] Cleanup dotfiles for cross-platform reliability Cross-platform reliability fixes for shell configs and git aliases Feb 16, 2026
Copilot AI requested a review from dbmrq February 16, 2026 15:53
@dbmrq dbmrq marked this pull request as ready for review February 16, 2026 15:53
@dbmrq dbmrq requested review from Copilot and removed request for dbmrq February 16, 2026 15:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves dotfiles portability across macOS (Apple Silicon + Intel) and BSD-like environments by removing hard-coded paths/flags and adjusting shell/git defaults to avoid breakage and alias shadowing.

Changes:

  • Make Homebrew initialization in Zsh/.zprofile resilient to both /opt/homebrew and /usr/local.
  • Reorder Zsh startup so shared shell config is sourced earlier, and centralize editor detection in .shell_common.
  • Modernize a few shared aliases/config defaults (BSD-compatible duh, zipr function, Git push/discard aliases) and avoid stow package errors on non-Darwin.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Zsh/.zshrc Removes duplicate editor exports and sources ~/.shell_common earlier to establish baseline aliases/env before “modern CLI” overrides.
Zsh/.zprofile Removes editor exports and guards brew shellenv for both Apple Silicon and Intel Homebrew locations.
Shell/.shell_common Switches zipr to a function and updates duh to use BSD-compatible du -d.
Git/.gitconfig-essential Updates push default to simple and changes discard alias to use git restore.
Bootstrap/stow.sh Skips Hammerspoon/ and TeX/ when not on Darwin to prevent stow failures.
README.md Marks Zsh/ as supported on both platforms in the structure table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Shell/.shell_common Outdated
Comment thread Bootstrap/stow.sh Outdated
Comment on lines +59 to +62
if [[ "$(uname -s)" != "Darwin" ]]; then
[[ "$dir" == "Hammerspoon/" ]] && continue
[[ "$dir" == "TeX/" ]] && continue
fi
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uname -s is executed once per directory iteration. Since the OS value is constant for the script run, compute it once (e.g., local os=$(uname -s)) before the loop (or before the if) and reuse it to reduce repeated subprocess calls and simplify the condition.

Copilot uses AI. Check for mistakes.
Comment thread Git/.gitconfig-essential
Comment thread README.md
| `Yazi/` | Both | Yazi file manager configuration |
| `Zellij/` | Both | Zellij terminal multiplexer configuration |
| `Zsh/` | macOS | Zsh configuration (standalone) |
| `Zsh/` | Both | Zsh configuration (standalone) |
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table now marks Zsh/ as "Both", but later this section still says "Platform-specific options are in .bash_aliases (Linux) and .zshrc (macOS)." That sentence looks outdated given .zshrc contains Linux paths/logic as well; consider updating it for consistency.

Copilot uses AI. Check for mistakes.
Comment thread Zsh/.zprofile
export VISUAL='vim'
# Pager
export PAGER='less'

Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDITOR/VISUAL are no longer set in .zprofile, so they won't be defined for login shells that don't read .zshrc (e.g., non-interactive login shells). If you still want these variables available in that scenario, consider sourcing ~/.shell_common from .zprofile (or keeping minimal EDITOR/VISUAL exports here).

Suggested change
# Editor
export EDITOR='vim'
export VISUAL="$EDITOR"

Copilot uses AI. Check for mistakes.
dbmrq and others added 2 commits February 16, 2026 13:01
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI and others added 2 commits February 16, 2026 16:07
Co-authored-by: dbmrq <15813674+dbmrq@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI and others added 2 commits February 16, 2026 16:27
@dbmrq dbmrq merged commit 626825b into master Feb 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants