Skip to content

feat: add cross-shell compatibility to preserve bash config when switching to zsh#900

Merged
marcusquinn merged 1 commit intomainfrom
feature/shell-compat
Feb 10, 2026
Merged

feat: add cross-shell compatibility to preserve bash config when switching to zsh#900
marcusquinn merged 1 commit intomainfrom
feature/shell-compat

Conversation

@marcusquinn
Copy link
Owner

Summary

  • Adds setup_shell_compatibility() step to setup.sh that runs after Oh My Zsh installation
  • When users switch from bash to zsh, their PATH entries, aliases, exports, and tool integrations (nvm, pyenv, brew, etc.) are preserved via a shared ~/.shell_common profile
  • Both .zshrc and bash configs source this shared file, so users maintain one config for both shells

Problem

Setup offers to install Oh My Zsh and change the default shell to zsh. Users who accept lose all their bash customizations — PATH entries, aliases, exports, and tool integrations like nvm/pyenv/brew shellenv. This is especially painful on macOS where many users have years of bash config from before Catalina switched the default to zsh.

Solution

Best-practice shared profile pattern:

  1. Scans .bash_profile, .bashrc, and .profile for portable customizations
  2. Extracts exports, aliases, PATH entries, eval/source commands into ~/.shell_common
  3. Skips bash-specific syntax (shopt, PS1, completion, bind, HISTCONTROL, etc.)
  4. Deduplicates lines across files (handles Linux's .bash_profile sourcing .bashrc)
  5. Adds POSIX dot-source (.) to both .zshrc and bash configs
  6. Users edit ~/.shell_common for shared settings, shell-specific files for the rest

Platform Support

  • macOS: Scans .bash_profile + .bashrc (both common), creates/updates .zshrc
  • Linux: Scans .bashrc + .profile + .bash_profile, handles all common layouts
  • Uses POSIX . (dot-source) instead of source for maximum compatibility
  • Gracefully skips if zsh or bash is not installed

Quality

  • Zero new ShellCheck violations
  • Bash syntax check passes
  • Opt-in [Y/n] prompt (default yes), idempotent (skips if ~/.shell_common exists)
  • Follows existing setup.sh patterns (local var="$1", explicit returns, confirm_step)

When setup installs Oh My Zsh or changes the default shell to zsh,
users lose their bash customizations (PATH entries, aliases, exports,
tool integrations like nvm/pyenv/brew).

Add setup_shell_compatibility() that:
- Scans .bash_profile, .bashrc, and .profile for portable customizations
- Extracts exports, aliases, PATH entries, eval/source commands
- Skips bash-specific syntax (shopt, PS1, completion, bind, etc.)
- Deduplicates lines across files (handles .bash_profile sourcing .bashrc)
- Creates ~/.shell_common with the extracted config
- Adds sourcing to both .zshrc and bash configs
- Users can then edit one file for both shells

Works on macOS (bash_profile + bashrc) and Linux (bashrc + profile).
Uses POSIX dot-source (.) for maximum shell compatibility.
Opt-in with [Y/n] prompt, idempotent (skips if already configured).
@gemini-code-assist
Copy link

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 52 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/shell-compat

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 29 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Tue Feb 10 03:46:38 UTC 2026: Code review monitoring started
Tue Feb 10 03:46:39 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 29

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 29
  • VULNERABILITIES: 0

Generated on: Tue Feb 10 03:46:41 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit 7b914d0 into main Feb 10, 2026
10 checks passed
@marcusquinn marcusquinn deleted the feature/shell-compat branch February 21, 2026 01:59
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.

1 participant