#!/bin/bash

#
# .void.bashrc
#

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

#################################
# Mandatory source files
# - bash-completion
# - bash-aliases
# - ps1 # replaced by starship, legacy

# always bash-completion first
[[ -r /usr/share/bash-completion/bash_completion ]] &&\
    source /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 ]] &&\
    source ~/.bash_aliases

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

#################################
# Optional source files

# BEGIN_KITTY_SHELL_INTEGRATION
[[ -n "$KITTY_INSTALLATION_DIR" ]] &&\
    [[ -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash" ]] &&\
    source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"
# END_KITTY_SHELL_INTEGRATION

# Google CLI
[[ -r ~/.googlerc ]] && source ~/.googlerc

#################################
# 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=50000
HISTFILESIZE=50000

# 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
# - direnv
# - starship
# - zoxide

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

#################################
# Environment variables

export XBPS_DISTDIR="$HOME/git/void-packages"
export SVDIR="$HOME/sv"
export PASSWORD_STORE_ENABLE_EXTENSIONS=true
export PASSWORD_STORE_EXTENSION_COMMANDS="tessen otp"

