PackageSwitcher is a native macOS utility for switching the shell environment in your existing
.bash_profile between Homebrew and MacPorts.
PackageSwitcher is designed for people who use Homebrew and MacPorts on the same Mac and want a clearer, safer way to choose which package manager takes precedence in new Terminal sessions.
Both package managers can coexist. When they provide commands with the same name, the version found earlier in PATH usually runs. PackageSwitcher makes the relevant profile lines visible, previews the result, and shows a diff before writing any changes.
MacPorts has some security advantages because it requires sudo before installing packages, while Homebrew offers some packages that are not available in MacPorts. I decided to complicate my life by using both package managers, and PackageSwitcher makes it easier to switch between them. I have used this workflow and found it useful. If you are reading this and think there is a better approach, critique is welcome. Maybe I will learn something!
- Homebrew and MacPorts can both be installed on one Mac.
- Each package manager adds directories to the shell environment.
PATHorder determines which copy of an overlapping command runs.- Manual startup-file edits are easy to mistype or apply inconsistently.
- PackageSwitcher exposes the active state and the exact proposed changes.
- Each package manager has some packages which are unique.
-
Targets the current user's
~/.bash_profile. -
Detects the expected active Homebrew or MacPorts lines.
-
Switches between the exact Homebrew and MacPorts profile blocks used by the app.
-
Provides Current Profile, Preview After Applying, and Diff views.
-
Preserves unrelated
.bash_profilecontent. -
Creates a timestamped backup before writing:
.bash_profile.PackageSwitcherBackup-yyyyMMdd-HHmmss -
Writes the updated profile atomically.
-
Warns when expected Homebrew or MacPorts installation paths are unavailable.
PackageSwitcher does not use managed block markers and does not modify .zprofile, .zshrc, or other shell startup files.
- Install Homebrew
- Install MacPorts
- Uninstall packages
- Migrate packages between package managers
- Merge Homebrew and MacPorts dependency trees
- Make both package managers share a package database
- Automatically configure zsh startup files
- Switch between Homebrew and MacPorts
- Show the currently detected package manager
- Display the exact
.bash_profilepath being edited
- Current profile view
- Preview before applying
- Row-highlighted diff view
- Horizontal and vertical scrolling for long profile content
- Preview and diff before writing
- Timestamped backup created before each switch
- Atomic profile writes
- Unrelated profile content retained
- Native SwiftUI interface
- Light and dark mode support
- Localized status, warning, error, success, and accessibility text
- Support link in the app and About window
v1.0.1 release is in this repository. Download, unzip, move it to your applications directory, and right click to open it.
Alternatively, build PackageSwitcher from source using Xcode.
- Launch PackageSwitcher.
- Review the detected active package manager and profile path.
- Select Homebrew or MacPorts.
- Inspect Preview After Applying and Diff.
- Apply the switch.
- Open a new Terminal window, or restart Terminal, for the environment change to take effect.
PackageSwitcher edits shell startup configuration. Review the preview and diff before applying a change.
Before writing, the app saves the current .bash_profile in the same directory using a timestamped filename. To restore one manually:
cp ~/.bash_profile.PackageSwitcherBackup-YYYYMMDD-HHMMSS ~/.bash_profileReplace the timestamp with the backup you want to restore. You can also make your own backup before early use:
cp ~/.bash_profile ~/.bash_profile.backupBack up only the shell profile you actually use. PackageSwitcher itself edits .bash_profile only.
PackageSwitcher currently ships with these localizations:
| • English • Arabic • French • German • Hindi |
• Japanese • Korean • Portuguese • Simplified Chinese ( zh-Hans)• Spanish |
Arabic includes right-to-left interface support. Shell commands, paths, and environment variables remain left-to-right for readability and accuracy.
The app follows the language selected by macOS.
PackageSwitcher shows the current .bash_profile, a preview of what will be written, and a diff view so you can verify the exact changes before applying them.
After switching, open a new Terminal window and inspect the effective environment:
echo $SHELL
echo $PATH | tr ':' '\n'
which brew
which port
brew --prefix
port versionPackageSwitcher expects:
- Homebrew at
/opt/homebrew/bin/brew - MacPorts directories at
/opt/local/binand/opt/local/sbin
Homebrew installations under /usr/local are not detected by the current switching logic.
Requirements:
- macOS 14.3 or later
- Xcode with the macOS SDK
Build and run:
- Open
PackageSwitcher.xcodeprojin Xcode. - Select the PackageSwitcher scheme.
- Select My Mac as the run destination.
- Build and run with Command-R.
From the command line:
xcodebuild \
-project PackageSwitcher.xcodeproj \
-scheme PackageSwitcher \
-configuration Debug \
buildIf PackageSwitcher saves you time or helps you manage a dual Homebrew/MacPorts setup, you can buy me a coffee here:
☕ https://buymeacoffee.com/blackrockcity
PackageSwitcher is licensed under the GNU General Public License version 3.


