# system
alias update='sudo pacman -Syu && config submodule update --remote --recursive --init'
alias pac='sudo pacman'
alias vi='$EDITOR'
alias qcp='qmv -o tabsize=4'
alias qmv='qmv -o tabsize=4'

# 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/sway" && $EDITOR .)'
alias zconf='(cd "$ZDOTDIR/" && $EDITOR .) && . "$ZDOTDIR/.zshrc"'

# dev
gi() {
    curl -Lf "https://www.gitignore.io/api/${(j:,:)@}"
}
# https://wiki.archlinux.org/title/Podman#Permission_denied:_OCI_permission_denied
alias podman='DBUS_SESSION_BUS_ADDRESS= podman'
alias valgrind='epitest valgrind'

# 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"
}

function tmp() {
    cd "$(mktemp -dt "$1"XXX)"
}

# vim: ft=zsh
