# system
alias tmp='cd "$(mktemp -d)"'
alias update='sudo pacman -Syu && config submodule update --remote --recursive --init'
alias vi='$EDITOR'

# conf
alias config='git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"'
alias viconf='(cd "$XDG_CONFIG_HOME/nvim" && $EDITOR .)'
alias wconf='(cd "$XDG_CONFIG_HOME/suckless/dwm-6.4" && $EDITOR .)'
alias zconf='(cd "$ZDOTDIR/" && $EDITOR .) && . "$ZDOTDIR/.zshrc"'

# dev
alias make='make -j8'
gi() {
    curl -Lf "https://www.gitignore.io/api/${(j:,:)@}"
}

# compatibility
alias ssh='TERM=linux ssh'

# alias
function coloralias() {
    $1 $(echo - "${@:2}" | sed 's/--color=\w\+/--color=always/')
}

alias sudo='sudo '
alias watch='coloralias watch -c -- '
alias xargs='xargs '

function j() {
    local dests=($(find . -mount -maxdepth 5 -type d -path "*/$1" 2> /dev/null))
    local dest="${dests:-$1}"

    [ -n "${dests[2]}" ] && dest="$(printf '%s\n' "${dests[@]}" | fzf)"
    cd "$dest"
}
