From ced579ce0458b28f9e2359a8c3435b66cccbda7e Mon Sep 17 00:00:00 2001 From: Ben Hammel <6020291+bdhammel@users.noreply.github.com> Date: Tue, 17 Jun 2025 07:40:33 -0700 Subject: [PATCH] Add OS and shell detection with config symlinks --- bashrc | 11 ++++++++ makesymlinks.sh | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ zshrc | 11 ++++++++ 3 files changed, 95 insertions(+) create mode 100644 bashrc create mode 100644 zshrc diff --git a/bashrc b/bashrc new file mode 100644 index 0000000..e1c4e2f --- /dev/null +++ b/bashrc @@ -0,0 +1,11 @@ +# ~/.bashrc + +# Source global bash settings +if [ -f ~/dotfiles/bash_aliases ]; then + source ~/dotfiles/bash_aliases +fi + +# Load common aliases +if [ -f ~/dotfiles/aliases ]; then + source ~/dotfiles/aliases +fi diff --git a/makesymlinks.sh b/makesymlinks.sh index e3c30a3..92508b3 100755 --- a/makesymlinks.sh +++ b/makesymlinks.sh @@ -10,6 +10,78 @@ dir=~/dotfiles # dotfiles directory olddir=~/dotfiles_old # old dotfiles backup directory files=("bash_aliases" "vimrc" "vim" "tmux.conf" "gitignore_global" "inputrc" "zsh_aliases" "pdbrc" "pdbrc.py") # list of files/folders to symlink in homedir +# Add shell specific rc file +case "$(detect_shell)" in + zsh) + files+=("zshrc") + ;; + *) + files+=("bashrc") + ;; +esac + +detect_shell() { + basename "$SHELL" +} + +detect_os() { + local os="$(uname)" + case "$os" in + Darwin) + echo "macos" + ;; + Linux) + if [ -f /etc/os-release ]; then + . /etc/os-release + case "$ID" in + ubuntu) + echo "ubuntu" + ;; + rhel|centos) + echo "redhat" + ;; + *) + echo "linux" + ;; + esac + else + echo "linux" + fi + ;; + *) + echo "unknown" + ;; + esac +} + +os_specific_setup() { + local os_name + os_name=$(detect_os) + case "$os_name" in + macos) + echo "macOS detected" + if command -v brew >/dev/null 2>&1; then + xargs brew install < "$dir/brew_requirements.txt" + fi + ;; + ubuntu) + echo "Ubuntu detected" + if command -v apt-get >/dev/null 2>&1; then + sudo apt-get update + fi + ;; + redhat) + echo "RedHat detected" + if command -v yum >/dev/null 2>&1; then + sudo yum update -y + fi + ;; + *) + echo "OS $os_name not specifically handled" + ;; + esac +} + create_backup() { # Create dotfiles_old in homedir echo -n "Creating $olddir for backup of any existing dotfiles in ~ ..." @@ -98,6 +170,7 @@ main() { cd ~ || exit setup_new_files setup_git + os_specific_setup } diff --git a/zshrc b/zshrc new file mode 100644 index 0000000..111be02 --- /dev/null +++ b/zshrc @@ -0,0 +1,11 @@ +# ~/.zshrc + +# Source custom zsh settings +if [ -f ~/dotfiles/zsh_aliases ]; then + source ~/dotfiles/zsh_aliases +fi + +# Load common aliases +if [ -f ~/dotfiles/aliases ]; then + source ~/dotfiles/aliases +fi