#!/bin/sh

alias .f='git --git-dir="$HOME/.dotfiles"'
alias .hf='git --git-dir="$HOME/.hostfiles"'
alias :q='exit'
alias :wq='exit'

alias aliases='$EDITOR ~/.config/aliasrc && . ~/.config/aliasrc'
alias aliases.local='$EDITOR ~/.config/aliasrc.local && . ~/.config/aliasrc'
# shellcheck disable=2154
alias arch-deps2deps='set -a; source PKGBUILD; set +a; paru -S --asdeps --noconfirm $depends && paru -Ui --rebuild'
alias artisan='./artisan'

alias bspwm-default='echo "default" > /tmp/bspwm_mode; bspc wm -r'
alias bspwm-present='echo "presenter" > /tmp/bspwm_mode; bspc wm -r'
alias bspwm-single='echo "single" > /tmp/bspwm_mode; bspc wm -r'

alias clip='xclip -selection clipboard'
alias cp='cp -iv'

alias dcu='docker compose up -d'
alias dcul='docker compose up -d && docker compose logs -tf'
alias dcp='docker compose pull'
alias df='df -h'
alias dns-flush='sudo systemctl restart systemd-resolved.service && sudo systemd-resolve --flush-caches && sudo resolvectl flush-caches'
alias doas='doas -- '
alias doasu='\doas -u '
alias docker-caddy-reload='docker compose exec app sh -c "caddy validate --config /etc/caddy/Caddyfile && caddy reload --config /etc/caddy/Caddyfile"'
alias du='du -h'

alias free='free -h'

alias git-apply-clip='wl-paste | base64 -d | git apply -'
alias grep='grep --color=auto'
alias grep-highlight='grep -e "^" -e'

alias hist-grep='history 0 | grep '

alias icat="kitty +kitten icat"
alias ip='ip -c'

alias j='jump'

alias keepass-unlock='(pkill keepassxc; pass keepass | head -n 1 | keepassxc --pw-stdin ~/sync/passwords.kdbx) & disown'

alias less='less -FS -x4'
alias ls='ls -lFh --color=auto'
alias lsblk='lsblk -o +LABEL,FSTYPE'

alias make='make -j5'
alias mkdir='mkdir -pv'
alias mv='mv -iv'

alias nixos-rebuild-tinker='sudo nixos-rebuild switch -p tinkering --no-build-nix'

alias pacman-autoremove='sudo pacman -Rns $(pacman -Qtdq)'
alias pacman-autoremove-opts='sudo pacman -Rns $(pacman -Qttdq)'
alias ps-grep='ps aux | grep -v grep | grep'

alias qutebrowser-kiosk='qutebrowser -B $XDG_DATA_HOME/qutebrowser-kiosk -C $XDG_CONFIG_HOME/qutebrowser/config-kiosk.py'

alias rm='rm -I --one-file-system -v'

alias sail='bash vendor/bin/sail'
alias sl='ls'
alias sudo='sudo '

alias tokei='tokei --hidden'

alias watch='watch -c'
alias wget='wget -c'

alias xdebug='XDEBUG_CONFIG="remote_host=127.0.0.1 remote_port=9003"'

### conditionals

[ -x "$(command -v bat)" ] && alias cat='bat -pp'

[ -x "$(command -v eza)" ] && alias ls='eza -lhF --git --icons --color=always --color-scale --time-style=long-iso --group-directories-first'

[ -x "$(command -v moar)" ] && alias less='moar'

[ -x "$(command -v nvim)" ] && alias vim='nvim'

[ -x "$(command -v rmtrash)" ] && alias rm='rmtrash -I --one-file-system -v'
[ -x "$(command -v rmdirtrash)" ] && alias rmdir='rmdirtrash'

[ -f "$HOME/.config/aliasrc.local" ] && . "$HOME/.config/aliasrc.local"