alias vim="nvim"

# Linux
alias ip="ip --color=auto"
alias la="ls -lah"

# git helpers
alias gf="git fetch --prune"
alias gs="git status"
alias gsw="git switch"
alias ga="git add -A"
alias gb="git branch -v"
alias grh="git add -A; git reset --hard"
alias grr="git restore"
alias gp="git pull"
alias gpp="git push"
alias grsf="git reset --soft HEAD~1"
alias grhf="git reset --hard HEAD~1"
alias grhk="git reset HEAD^" # keep changes
alias gc="git commit -m"
alias grep="grep --color=auto"
alias gd="git diff"
alias gcl="git clean -dfx"

gpu() {
current_branch="$(git rev-parse --abbrev-ref HEAD)"
echo "Pushing to origin $current_branch"
git push -u origin $current_branch
}

gmm() {
current_branch="$(git rev-parse --abbrev-ref HEAD)"
echo "Merging master into $current_branch"
gpl
gsw master
gp
gsw $current_branch
git merge origin master
}

# Other
alias dcl="dotnet clean && dotnet restore"
alias random="tr -dc A-Za-z0-9 </dev/urandom | head -c 13; echo"

# Plabble
clip() {
	url=$(curl -sF 'content=<-' https://paste.plabble.org/$1 -w '\n')
	echo $url
	echo $url | pbcopy
}

unclip() {
	curl https://paste.plabble.org/$1
}

# NNN
n() {
	if [[ "${NNNLVL:-0}" -ge 1 ]]; then
		echo "nnn is already running"
		return
	fi

	# export to always-cd
	NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

	nnn "$@"

	if [ -f "$NNN_TMPFILE" ]; then
		. "$NNN_TMPFILE"
        	rm -f "$NNN_TMPFILE" > /dev/null
	fi
}

add_to_path() {
    if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
        PATH="${PATH:+"$PATH:"}$1"
    fi
}


# PATH
add_to_path "$HOME/.cargo/bin"

export EDITOR="nvim"