globalvar GIT_USE_ICONS 0 "Enables Icons in prompt"
globalvar GIT_FETCH_CACHE_TIME 3600 "Frequency in which the fossil remote cache should be checked"

function _deps(){
	app="fossil"

	$(hash $app 2>/dev/null) || ( myzsh error "Couldn't find application ${app}" && return 1 )
}

function fossil_func () {
	local infossil
	fossil branch >/dev/null 2>/dev/null
	infossil=$?
	if [ "$infossil" != 0 ]; then
		return
	fi
	local current_ver
	local min_ver
	local fossilstatus
	local stash

	branch=$(fossil branch | awk '/^\*/ {print $2}' | sed 's/(//')

	printf "%s" "$branch"

	fossilStatus="$(fossil status --differ | while read -r s _; do [[ "$s" =~ "^[A-Z]" ]] || continue; echo ${s:0:1}; done | uniq -c | while read -r a b; do printf " $b:$a"; done)"
	printf "%s" "${fossilStatus}"
}

# TODO
# - figure out self hosting, cgi maybe? https://www.fossil-scm.org/index.html/doc/trunk/www/server.wiki
# - get this added to a repo somewhere
# - repo sync script, omg
# - make 'checkout' make a directory, put repo in .fossil
# - make 'wiki edit' export to a mktemp, then commit it back

OUTPUT=fossil_func
# vim: filetype=zsh noexpandtab
