- Overview: Create a new script (e.g.,
dotfiles/.config/helpers/common_helpers.sh) that defines helper functions such asopen_current_pr. Source this script from bothzsh_profileandbash_profile. - Steps:
- Add the helper script under
dotfiles/.config/helpers/and define functions there. - Update
dotfiles/zsh_profileanddotfiles/bash_profileto source the script (e.g.,source "$HOME/.config/helpers/common_helpers.sh"). - Ensure
setup_dotfileslinks the helper directory or copies it alongside other config files.
- Add the helper script under
- Pros: Single source of truth; easy to extend for new helpers; consistent behavior across shells.
- Cons: Requires ensuring the helper script is distributed/linked on all machines; adds another file to manage in dotfiles syncing.
- Overview: Define helper functions directly inside
dotfiles/zsh_profileanddotfiles/bash_profile, possibly in a dedicated section. - Steps:
- Add a clearly labeled section (e.g.,
# Helper functions) to both profile files. - Insert shared functions in both files (or conditionally load if shell-specific).
- Re-run
./setup_dotfilesto propagate the updates.
- Add a clearly labeled section (e.g.,
- Pros: Simple setup; no additional sourcing or file creation; aligns with current dotfile layout.
- Cons: Duplicates logic across files; harder to maintain if many helpers are added; increases profile file size.
- Overview: Create a
helpers.d/directory where each helper lives in its own file. Profiles iterate through the directory and source each helper dynamically. - Steps:
- Create
dotfiles/helpers.d/and add helper files (e.g.,open_pr.shdefining the function). - Modify
zsh_profileandbash_profileto source all readable files in the directory:for helper in "$HOME/.helpers.d/"*.sh; do source "$helper"; done. - Update
setup_dotfilesto copy or linkhelpers.d/to$HOME/.helpers.d/.
- Create
- Pros: Highly modular; easy to enable/disable individual helpers; scalable for future additions.
- Cons: Slightly more complex logic; requires directory management and consistent naming; shell startup may be marginally slower if many files exist.