#
# Stop emacs tramp from hanging when working remotly
#
[[ $TERM == "dumb" ]] && unsetopt zle && PS1='$ ' && return

#
# Set oh-my-zsh path
#
export ZSH=$HOME/.oh-my-zsh

#
# Disable applications setting the terminal title globally not just in
# oh-my-zsh as it was previously
#
export DISABLE_AUTO_TITLE=true

#
# Configure oh-my-zsh
#
ZSH_THEME="pygmalion"
ENABLE_CORRECTION="false"
COMPLETION_WAITING_DOTS="true"

#
# Set oh-my-zsh plug-ins
#
# More plug-ins are loaded in ~/.oh-my-zsh/custom/lib/misc.zsh file so we dint
# have to define all of the custom installed plug ins here.
#
plugins=(git extract)

#
# map ecs to caps lock
#
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'

#
# Change cursor shape
#
# Block     ▇ printf '\033[1 q'
# Underline _ printf '\033[3 q'
# Beam      | printf '\033[5 q'
#
printf '\033[5 q'

#
# Configure base16 shell for colors if the terminal is not running inside of
# emacs or vim
#
if [[ -z "$VIM" ]] && [[ -z "$INSIDE_EMACS" ]] && [[ -z "$SSH_TTY" ]] ; then
  BASE16_CONFIG_PATH="$HOME/.config/base16-shell/"
  [ -s "$BASE16_CONFIG_PATH/profile_helper.sh" ] && source "$BASE16_CONFIG_PATH/profile_helper.sh"
fi

#
# Setup and export $PATH
#
if [ -d $HOME/.local/share/go ]; then
    export PATH=$PATH:$HOME/.local/share/go/bin
fi

if [ -d $HOME/.local/bin ]; then
    export PATH=$PATH:$HOME/.local/bin
fi

if [ -d $HOME/development/flutter ]; then
    export PATH=$PATH:$HOME/development/flutter/bin
fi

export PATH=$PATH:$HOME/.config/composer/vendor/bin

#
# Set up golang
#
if [ -d $HOME/Code ]; then
    export GOPATH=$HOME/Code
    export PATH=$PATH:$GOPATH/bin
fi

export EDITOR="nvim"

#
# Import local alases if the file exists
#
if [ -f ~/.aliases ]; then
    source ~/.aliases;
fi

#
# Make vim and vi neovim
#
if type nvim > /dev/null 2>&1; then
  alias vim='nvim'
  alias vi='nvim'
fi

# Load php env
export PHPENV_ROOT="/home/ade/.phpenv"
if [ -d "${PHPENV_ROOT}" ]; then
    export PATH="${PHPENV_ROOT}/bin:${PATH}"
    eval "$(phpenv init -)"
fi

# Ruby version manager (RVM)
if [ -f "/etc/profile.d/rvm.sh" ]; then
    source "/etc/profile.d/rvm.sh"
fi

if [ -d "$HOME/.local/share/adr-tools/src" ]; then
  PATH="$PATH:$HOME/.local/share/adr-tools/src"
fi

# Set up the rust dev environment
if [ -f "$HOME/.cargo/env" ]; then
    . "$HOME/.cargo/env"
fi

# Node version manager (NVM)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# Export the bat theme to integrate with base16 nicely
# https://github.com/sharkdp/bat#highlighting-theme
export BAT_THEME="base16"

#
# Init oh-my-zsh
#
source $ZSH/oh-my-zsh.sh

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
