#
# ~/.bashrc
#

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

export EDITOR="nvim"
export VISUAL="nvim"
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk
export PATH=$PATH:$JAVA_HOME/bin
export HADOOP_HOME=/opt/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop

# android developpement
export ANDROID_SDK_ROOT='/opt/android-sdk'
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin/
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/

alias ls='ls --color=auto'
alias grep='grep --color=auto'
PS1='[\u@\h \W]\$ '

alias olagem='sudo /root/.cargo/bin/olagem'
alias tartar='sudo tar -xvzf'
alias zz="history | fzf | sed 's/^[ \t]*[0-9]*[ \t]*//' | bash"
alias update='sudo pacman -Syu'
alias flush="rm -rf ~/.local/share/Trash/*"
alias tp='trash-put'
alias power='upower -i /org/freedesktop/UPower/devices/battery_BAT0'
alias space='df -h /'
alias cache='sudo pacman -Sc && docker system prune -a --volumes && flush'
virus() {
    sudo freshclam
    local cible=${1:-.}
    clamscan -r --bell "$cible"
}
alias die='shutdown -h now'
alias protu='ls -la -h'
alias ll='ls -a'
alias lg='lazygit'
alias cl='clear'
alias pac='sudo pacman -Syu'
alias nv='nvim'
alias bim='sudo nvim'
alias sc='syncthing --browser-only'
alias gp='sudo -E gparted'
alias ddd='sudo dd bs=4M status=progress oflag=sync'
ff() {
    firefox "$@" & disown
}
function search {
    if [ $# -ne 2 ]; then
        folder="."
	wanted="$1"
    else
	folder="$1"
	wanted="$2"
    fi
    sudo find "$folder" -name "$wanted" 2>/dev/null
}
where() {
    sudo find / -name "$1" 2>/dev/null
}
alias t='tree -d'
setGithub() {
  if [ $# -lt 1 ]; then
    echo "Usage: setGithub <git-url>"
    return 1
  fi

  local newurl="$1"

  if ! git rev-parse --show-toplevel >/dev/null 2>&1; then
    echo "Not a git repository (or no .git found in this directory or parents)."
    return 3
  fi

  if git remote set-url origin "$newurl"; then
    echo "Updated origin to: $newurl"
    git remote -v
    return 0
  else
    echo "Failed to update remote origin"
    return 4
  fi
}

# Generated for envman. Do not edit.
[ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh"
alias setUser='git config --global credential.helper store'

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


# Load Angular CLI autocompletion.
source <(ng completion script)
export PATH="$HOME/.cargo/bin:$PATH"


# BEGIN opam configuration
# This is useful if you're using opam as it adds:
#   - the correct directories to the PATH
#   - auto-completion for the opam binary
# This section can be safely removed at any time if needed.
test -r '/home/pluto/.opam/opam-init/init.sh' && . '/home/pluto/.opam/opam-init/init.sh' > /dev/null 2> /dev/null || true
# END opam configuration
