# vim:set ft=zsh
# sudo not required for some system commands
for command in mount umount sv pacman xbps-install xbps-remove apt aptitude updatedb su shutdown poweroff reboot; do
	command -v $command 1>/dev/null 2>&1 && alias $command="sudo $command"
done
unset command

# Verbosity and settings that you pretty much just always are going to want.
alias \
	vim="nvim" \
	cp="cp -iv" \
	mv="mv -iv" \
	rm="rm -vI" \
	bc="bc -ql" \
	mkd="mkdir -pv" \
	ffmpeg="ffmpeg -hide_banner" \
	grep="grep --color=auto" \
	diff="diff --color=auto" \
	nvidia-settings="nvidia-settings --config=$XDG_CONFIG_HOME/nvidia/settings"

# Colorize commands when possible.
alias \
	ls="ls -hN --color=auto --group-directories-first" \
	grep="grep --color=auto" \
	diff="diff --color=auto" \
	ccat="highlight --out-format=ansi" \
	ip="ip -color=auto"

# These common commands are just too long! Abbreviate them.
alias \
	ka="killall" \
	e="$EDITOR" \
	z="zathura"

if command -v pacman 1>/dev/null 2>&1; then
	alias p="pacman"
fi

if command -v apt 1>/dev/null 2>&1; then
    alias \
        ain="apt install" \
        are="apt remove" \
        arein="apt reinstall" \
        aur="apt autoremove" \
        aup="apt upgrade" \
        ase="apt search" \
        ash="apt show"
fi

if command -v xbps-install 1>/dev/null 2>&1; then
    alias \
       xin="xbps-install" \
       xup="xbps-install -Syu" \
       xre="xbps-remove" \
       xse="xbps-query -Rs"
fi


# Misc.
alias \
    ll="ls -lhpAN --color=auto --group-directories-first" \
	ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \
	weath="less -S ${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" \
	remvirt="virt-manager -c 'qemu+ssh://luca@192.168.178.200/system'" \
	wikidown='rclone sync cloud:files/luca/Notes ~/Documents/vimwiki' \
	wikiup='rclone sync ~/Documents/vimwiki cloud:files/luca/Notes' \
	ahv="export ANSIBLE_VAULT_PASSWORD_FILE=~/.ansible/secrets/ansible-homelab && ansible-vault" \
    xgetkeys="xev | sed -ne '/^KeyPress/,/^$/p'" \
	xpick=" xprop | awk '     
        /^WM_CLASS/{sub(/.* =/, \"instance:\"); sub(/,/, \"\nclass:\"); print}
        /^WM_NAME/{sub(/.* =/, \"title:\"); print}'"