#
# ~/.bashrc
#

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

# Env
export EDITOR=nvim


# Keybinds
bindkey -M emacs '^H' backward-kill-word # ctrl + bksp = delete word before cursor
bindkey -M emacs '^[[3;5~' kill-word     # ctrl + del  = delete word after cursor
bindkey -M emacs '^[[1;5D' backward-word # ctrl +     = move cursor to start of last word
bindkey -M emacs '^[[1;5C' forward-word  # ctrl +     = move cursor to end of next word

# fnm
FNM_PATH="$HOME/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
  export PATH="$FNM_PATH:$PATH"
  eval "`fnm env`"
fi
. "$HOME/.cargo/env"

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:/opt/android-sdk/platform-tools:$PATH"

if [ -f "$HOME/.zsh_aliases" ]; then
  source $HOME/.zsh_aliases
fi

eval "$(starship init zsh)"

# Archive Extraction
# Taken from https://gitlab.com/dwt1/dotfiles

function ex {
 if [ -z "$1" ]; then
    # display usage if no parameters given
    echo "Usage: ex <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
    echo "       extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
 else
    for n in "$@"
    do
      if [ -f "$n" ] ; then
          case "${n%,}" in
            *.cbt|*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
                         tar xvf "$n"       ;;
            *.lzma)      unlzma ./"$n"      ;;
            *.bz2)       bunzip2 ./"$n"     ;;
            *.cbr|*.rar)       unrar x -ad ./"$n" ;;
            *.gz)        gunzip ./"$n"      ;;
            *.cbz|*.epub|*.zip)       unzip ./"$n"       ;;
            *.z)         uncompress ./"$n"  ;;
            *.7z|*.arj|*.cab|*.cb7|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.pkg|*.rpm|*.udf|*.wim|*.xar)
                         7z x ./"$n"        ;;
            *.xz)        unxz ./"$n"        ;;
            *.exe)       cabextract ./"$n"  ;;
            *.cpio)      cpio -id < ./"$n"  ;;
            *.cba|*.ace)      unace x ./"$n"      ;;
            *)
                         echo "ex: '$n' - unknown archive method"
                         return 1
                         ;;
          esac
      else
          echo "'$n' - file does not exist"
          return 1
      fi
    done
fi
}


autoload -U compinit
compinit

# plugins
if [ -f "$HOME/.zsh_plugin_loader.sh" ]; then
  . $HOME/.zsh_plugin_loader.sh
fi


. "$HOME/.local/bin/env"


export PATH=$PATH:/home/bad/.spicetify
export PATH=$PATH:/home/bad/bin
