#
# ~/.bashrc
#

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

# aliases
alias ls='ls --color=auto'
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'

if [ -f /usr/bin/vim ]; then
   alias vi='vim'
fi

if [ -f /usr/bin/resolvectl ]; then
   alias nslookup='resolvectl query'
fi

if [ -e ~/.bashrc.aliases ]; then
   # shellcheck disable=SC1090
   source ~/.bashrc.aliases
fi

# prompt

fancy_prompt="yes"

if [[ "$fancy_prompt" == "yes" && "$TERM" != "xterm" && "$TERM" != "xterm-256color"  && "$XDG_SESSION_TYPE" != "tty" ]]; then
   # shellcheck disable=SC1090,SC1091 
   source /usr/local/share/amt/bash-prompt.sh
else
   if [ "$UID" != 0 ]; then
      PS1="[\[\033[1;35m\]\u\[\033[m\]@\[\033[1;32m\]\h\[\033[m\]]\[\033[0;36m\]\w\[\033[m\]\[\e[1;33m\]$\[\e[0m\] "
   else
      PS1="[\[\033[1;31m\]\u\[\033[m\]@\[\033[1;32m\]\h\[\033[m\]]\[\033[0;36m\]\w\[\033[m\]$ "
   fi
   PS2="\033[1;32m>\033[0m "
fi

# bash completion
if [ -r /usr/share/bash-completion/bash_completion ]; then
   # shellcheck disable=SC1090,SC1091 
   source /usr/share/bash-completion/bash_completion
fi

# color
test -r ~/.dircolors && (eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)")

# gcc
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# bash tuning
shopt -s direxpand
shopt -s checkhash
shopt -s checkwinsize
shopt -s expand_aliases
shopt -s autocd cdspell
shopt -s extglob dotglob
shopt -s no_empty_cmd_completion
shopt -s autocd cdable_vars cdspell
shopt -s cmdhist histappend histreedit histverify

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

export BROWSER=/usr/bin/firefox
export EDITOR=/usr/bin/vim

# Video hardware support
#export VDPAU_DRIVER=nvidia
#export LIBVA_DRIVER_NAME=vdpau

# socks based firefox
function firefoxy  {
   port=3012
   export SOCKS_SERVER=localhost:$port
   export SOCKS_VERSION=5
   /usr/bin/firefox &
   exit
}

# User path
export PATH="$PATH:/home/$USER/bin"

# Tor-Browser
export TORBROWSER_PKGLANG='en-US'

# fetch brothers
if [ -f /usr/bin/fastfetch ]; then
   /usr/bin/fastfetch
elif [ -f /usr/bin/screenfetch ]; then
   /usr/bin/screenfetch
elif [ -f /usr/bin/neofetch ]; then
   /usr/bin/neofetch
elif [ -f /usr/bin/hyfetch ]; then
   /usr/bin/hyfetch
fi

# System info
if [ -f /usr/local/bin/config_fetch.sh ]; then
   /usr/local/bin/config_fetch.sh
fi

