185 lines · 5.5 KB
#!/usr/bin/env bash
# Where our dotfiles repo lives
export DOTFILES="$HOME/.dotfiles"

os="$(which_os)"

# OS/Distro specific stuff
case "$os" in
nixos)
    alias ls='ls --color=auto'
    PS1='[\u@\h \W]\$ '

    alias zzz="sudo systemctl suspend"
    ;;

debian)
    # shellcheck disable=1091
    if ! shopt -oq posix; then
        if [ -f /usr/share/bash-completion/bash_completion ]; then
            . /usr/share/bash-completion/bash_completion
        elif [ -f /etc/bash_completion ]; then
            . /etc/bash_completion
        fi
    fi
    ;;

darwin)
    # Brew on Apple Silicon lives in /opt/homebrew and needs to initialize
    # in the shell with a script.
    bash_bin_arm="/opt/homebrew/bin/brew"
    if [[ $(uname -m) == "arm64" && -f $bash_bin_arm ]]; then
        eval "$("$bash_bin_arm" shellenv)"
    fi

    # Make sure XDG_CONFIG_HOME is a thing
    if [[ -z $XDG_CONFIG_HOME ]]; then
        export XDG_CONFIG_HOME="$HOME/.config"
    fi
    mkdir -p "$XDG_CONFIG_HOME"