#!/bin/env bash set -e mkdir -p "$HOME/.bashrc.d" FILE="$HOME/.bashrc" BLOCK=' if [ -d ~/.bashrc.d ]; then for rc in ~/.bashrc.d/*; do if [ -f "$rc" ]; then . "$rc" fi done fi ' if ! grep -Fqs ".bashrc.d" "$FILE"; then echo "$BLOCK" >> "$FILE" else echo ".bashrc.d block already exists" fi