#!/bin/sh

# Use $XINITRC variable if file exists.
[ -f "$XINITRC" ] && alias startx="startx $XINITRC"

[ -f "$MBSYNCRC" ] && alias mbsync="mbsync -c $MBSYNCRC"

# sudo not required for some system commands
for command in mount umount updatedb su shutdown poweroff reboot ; do
	alias $command="sudo $command"
done; unset command

alias \
	e="emacsclient -tty -a ''" \
	emc="setsid -f emacsclient -c -a '' >/dev/null 2>&1" \
	emo="emacsclient" \
	kem="emacsclient -e '(kill-emacs)'" \
	vimdiff="nvim -d" \
	cp="cp -iv" \
	mv="mv -iv" \
	rm="rm -vI" \
	bc="bc -ql" \
	mkd="mkdir -pv" \
	ffmpeg="ffmpeg -hide_banner" \
	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" \
	ka="killall" \
	g="git" \
	sdn="shutdown -h now" \
	v="nvim" \
	z="zathura" \
	d="sdcv" \
	i="nsxiv -a" \
	pg="ps -aux | grep --color=auto" \
	weath="curl wttr.in" \
	ytmus="yt-dlp --embed-metadata --embed-thumbnail -xc -f 'bestaudio[ext=m4a]'" \
	ytvid="yt-dlp --embed-metadata --embed-thumbnail --embed-chapters --write-auto-subs -f bestvideo'[height<=1080]''[ext=mp4]'+bestaudio'[ext=m4a]'/best'[ext=mp4]'/best" \
	hgs="hugo server --noHTTPCache --disableFastRender" \
	left='uxnemu ~/.local/uxn/left.rom' \
	bouc='uxnemu ~/.local/uxn/bouc.rom' \
	catclock='uxnemu ~/.local/uxn/catclock.rom' \
	b='$BROWSER'\
	sc='sc-im'\
	l='ledger -f ~/notebook/ac/ac.ledger'

wedit(){
which $@ >/dev/null 2>&1 && [ -n "$1" ] && $EDITOR $(which $@) || printf "file doesn't exist.\n"
}