#!/bin/bash

#
# .void.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

#################################
# - bash_aliases
# - bash-completion

# always bash-completion first
[[ -r /usr/share/bash-completion/bash_completion ]] && . /usr/share/bash-completion/bash_completion

# custom bash-completions
[ -d ~/.config/completions ] && { for i in ~/.config/completions/*; do source $i; done }

# source distro and general purpose aliases
[[ -r ~/.bash_aliases ]] && . ~/.bash_aliases

# integrate git prompt functions
# will break PS1 if not used
[[ -f /usr/share/git/git-prompt.sh ]] && . /usr/share/git/git-prompt.sh

# kube-ps1
# located in ~/git/kube-ps1
[[ -r ~/git/kube-ps1/kube-ps1.sh ]] && . ~/git/kube-ps1/kube-ps1.sh

# set PS1 from file
# USE ONLY AFTER GIT PROMPT
[[ -r ~/.ps1 ]] && . ~/.ps1

#################################
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

#################################
# - hooks

command -v direnv &>/dev/null && eval "$(direnv hook bash)"
command -v starship &>/dev/null && eval "$(starship init bash)"

# - env vars

export XBPS_DISTDIR="$HOME/git/void-packages"
export SVDIR="$HOME/sv"

# BEGIN_KITTY_SHELL_INTEGRATION
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
# END_KITTY_SHELL_INTEGRATION
