# CoreDesktop shell setup, sourced from ~/.bashrc (added by shell/setup.sh).
# Anything in ~/.bashrc after the line that sources this file overrides it.

# Only for interactive shells
[[ $- != *i* ]] && return

COREDESKTOP_SHELL="$HOME/.local/share/coredesktop/shell"

# History: keep a lot of it, skip duplicates, and don't let shells overwrite
# each other's history on exit
shopt -s histappend
HISTCONTROL=ignoreboth
HISTSIZE=32768
HISTFILESIZE="$HISTSIZE"

if [[ ! -v BASH_COMPLETION_VERSINFO && -f /usr/share/bash-completion/bash_completion ]]; then
  source /usr/share/bash-completion/bash_completion
fi

source "$COREDESKTOP_SHELL/aliases"
source "$COREDESKTOP_SHELL/functions"

# Prompt. Uses CoreDesktop's starship config unless you have your own.
if [[ $TERM != "dumb" ]] && command -v starship &> /dev/null; then
  [[ -f "$HOME/.config/starship.toml" ]] || export STARSHIP_CONFIG="$COREDESKTOP_SHELL/starship.toml"
  eval "$(starship init bash)"
fi

# z <part of a path> jumps to a directory you've visited before
if command -v zoxide &> /dev/null; then
  eval "$(zoxide init bash)"
fi

# Ctrl-R fuzzy history search, Ctrl-T to insert a file path, Alt-C to cd
if [[ -f /usr/share/fzf/key-bindings.bash ]]; then
  source /usr/share/fzf/key-bindings.bash
fi
