export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
export EDITOR="/usr/local/bin/nvim"

# vim
alias vim="nvim"

# ls
alias ls="ls --color=auto"

alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias .......="cd ../../../../../.."

# improved reset and clear
alias reset="tput reset"
alias clear="tput reset"

# better du
alias du="du -hd 1"

# better feh
alias feh="feh -."

# vi keybindings
alias info="info --vi-keys"
alias less="less -R"
alias sl="ls"
alias la="ls -a"
alias venv="source venv/bin/activate"

# search functions
alias grepa="grep -I -n --color=always -r --exclude-dir=venv --exclude-dir=node_modules"

# cat
alias cat="batcat -p --paging=never"

# pipe yd-dlp to mpv
ytmpv() {
	yt-dlp -q -o - "$1" | mpv -
}

goto() {
	open="$(grepa "$@" | fzf --ansi -1)"
	if [ ! -z "$open" ]; then
		file="$(echo "$open" | cut -d: -f1 -)"
		line="$(echo "$open" | cut -d: -f2 -)"

		vim "$file" -c "cd %:p:h" -c "normal! $line"gg
	fi
}

# NVM - Dynamic loading trick
alias nvm="unalias nvm && [ -z $NVM_LOADED ] && export NVM_LOADED=1 && source /usr/share/nvm/init-nvm.sh ; nvm"
alias node="unalias node && [ -z $NVM_LOADED ] && export NVM_LOADED=1 && source /usr/share/nvm/init-nvm.sh ; node"