Skip to content

Instantly share code, notes, and snippets.

@rot26
Last active November 26, 2022 02:56
Show Gist options
  • Save rot26/ed2c36ce0f810a5ec24359a550c0bace to your computer and use it in GitHub Desktop.
Save rot26/ed2c36ce0f810a5ec24359a550c0bace to your computer and use it in GitHub Desktop.
[.bashrc.d] Use bashrc directory instead of bashrc #bash #bashrc
# Add this to your ~/.bashrc file
# Use .bashrc.d directory instead of bloated .bashrc file
# From: https://waxzce.medium.com/use-bashrc-d-directory-instead-of-bloated-bashrc-50204d5389ff
BASHRC_DIR="${HOME}/.bashrc.d"
# Optionally create directory if not exists
if [ ! -d "${BASHRC_DIR}" ]; then
mkdir -p "${BASHRC_DIR}";
chmod 700 "${BASHRC_DIR}";
fi
# Load any *.bashrc files in ~/.bashrc.d/
if [ -d "${BASHRC_DIR}" ]; then
for file in ${BASHRC_DIR}/*.bashrc; do
source "${file}";
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment