LOCAL_GIT_DIR=${HOME}/.local/git

alias ga='git add .; git commit --no-edit --amend; git push --force-with-lease'
alias gae='git add .; git commit --amend; git push --force-with-lease'
alias less='less -R'
alias lg="lazygit"
alias qt="dbus-run-session qtile start -b wayland"

if [[ $(command -v bat) ]]; then
  alias cat='bat -pp --color=always --tabs=2 --theme=Monokai\ Extended\ Bright'
fi

if [[ $(command -v eza) ]]; then
  alias ls='eza --git --octal-permissions --no-permissions --group-directories-first'
  alias ll='eza --git --octal-permissions --no-permissions --group-directories-first -l'
else
  case $(uname -s) in;
    Darwin) alias ls='ls -G';;
    Linux)  alias ls='ls --color';;
  esac
  alias ll='ls -l'
fi

if [[ $(command -v fd) ]]; then
  if [[ -f ~/.local/config/fd ]]; then
    alias fd='fd -H -L --ignore-file ~/.local/config/fd'
  else
    alias fd='fd -H -L'
  fi
fi

if [ $(command -v nvim) ]; then
  export EDITOR=nvim
  export MANPAGER="nvim +Man!"
  alias vim=nvim
  alias vimdiff="nvim -d"
elif [ $(command -v vim) ] ; then
  export EDITOR=vim
else
  export EDITOR=vi
fi

if [[ $(command -v rg) ]]; then
  alias grep='rg -i'
else
  alias grep='grep --color'
fi

function ud() {
  for i in ${LOCAL_GIT_DIR}/dotfiles ${LOCAL_GIT_DIR}/zsh_modules/*; do git -C ${i} pull; done
  nvim -c "lua require('lazy').sync({wait = true})"
}
function upgrade() {
  case $(lsb_release -si) in
    Gentoo) eix-sync && eix-update && emerge -avuNDU @world ;;
    VoidLinux) xbps-install -Su && xbps-remove -RoO && xlocate -S ;;
  esac
}
