#!/usr/bin/env bash shopt -s globstar shopt -s histappend export HISTCONTROL=ignorespace:ignoredups:erasedups export HISTSIZE=1000 export HISTIGNORE="ls:cd:pwd:clear:exit:history:exit:shutdown:reboot" export PROMPT_DIRTRIM=2 export CLICOLOR=1 # 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' 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" export LSCOLORS=dxfxcxdxbxegedabagacad alias ls='ls -h' # Keep TAR from tarring-up resource forks export COPYFILE_DISABLE=true # Miscellaneous aliases alias brew-remove="brew list | sort | gum filter --no-limit | xargs brew remove" # Colored man pages export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m' ;; esac function nixPrompt() { case $IN_NIX_SHELL in pure) printf ' ' ;; impure) printf ' ' ;; *) printf '' ;; esac } red='\[\e[0;31m\]' yellow='\[\e[0;33m\]' cyan='\[\e[0;36m\]' violet='\[\e[38;5;63m\]' no_color='\[\e[0m\]' indigo='\[\e[38;2;90;86;224m\]' function prompt_func() { nix=$(nixPrompt) dimensions="$(tput cols)×$(tput lines)" git_branch=$(__git_ps1 " (%s)") if [[ -n $DEMO_PROMPT ]]; then PS1="$indigo>$no_color " else PS1="$indigo$dimensions $cyan\h:$red\w $cyan\u$yellow$git_branch$violet$nix $red\$ $no_color" fi } PROMPT_COMMAND=prompt_func gpg_TTY=$(tty) export GPG_TTY=$gpg_TTY alias nb='nix build -L' alias nr='nix run -L -j"$(num_cores)"' alias nrm='nix run -L -j"$(num_cores)" 2>&1 | tee >(mods "What does this NixOS output mean?")' alias code-review='git --no-pager diff | mods -f "code review this patch" | glow' alias filterkill='ps | awk "NR>1" | gum choose --header=" Kill Process?" | xargs kill' alias tree='tree -C' # Helper vars export MEOW='git@github.com:meowgorithm' export GITLAB='git@gitlab.com:meowgorithm' export CHARM='git@github.com:charmbracelet' export GOCHARM='github.com/charmbracelet' export GOMEOW='github.com/charmbracelet' # shellcheck disable=1091 if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash" fi # Go export GOPATH="$HOME/.go" # GHCUP # shellcheck disable=1091 [ -f "$HOME/.ghcup/env" ] && . "$HOME/.ghcup/env" # Direnv command -v direnv >/dev/null 2>&1 && eval "$(direnv hook bash)" paths=( "$HOME/.local/bin" "$HOME/.nix-profile/bin" "$HOME/.cargo/bin" "$HOME/.ghcup/bin" "$GOPATH/bin" "$HOME/.bin" ) # Add paths to the PATH. Note that we ensure the path exists and isn’t already # in the PATH. for dir in "${paths[@]}"; do if [[ -d $dir && ":$PATH:" != *":$dir:"* ]]; then PATH="${PATH:+"$PATH:"}$dir" fi done # Prioritize /usr/bin on macOS if [[ "$os" == "darwin" ]]; then export PATH="/usr/bin:$PATH" fi