~skiqqy/bin

0fe85e13f7ab97917dabbf07cb7d47eba78bba12 — Stephen Cochrane a month ago 61dcacd
Added performace
1 files changed, 14 insertions(+), 11 deletions(-)

M todo
M todo => todo +14 -11
@@ 4,8 4,16 @@

main()
{
	# TODO: Consider saving dir locally for performance.
	wdir="$(find "$HOME" -regex '.*/todo' -type d 2> /dev/null | head -1)"
	if [ ! -f '/tmp/todo.directory' ]
	then
		printf 'todo.directory not found, generating cache'
		wdir="$(find "$HOME" -regex '.*/todo' -type d 2> /dev/null | head -1)"
		printf "wdir=%s\n" "$wdir" > /tmp/todo.directory
	else
		printf 'todo.directory found, skipping $ find ...\n'
		. /tmp/todo.directory
	fi

	[ -z "$wdir" ] && printf 'Please create a "todo" directory...\n' && return 1
	term= # Terminal to launch todo in, default is curr shell



@@ 37,19 45,14 @@ main()
					pdf "$f"
				done
				;;
			pdf)
				select open in *.pdf
				do
					pdf "$open"
				done
				;;
			'')
				run="select open in *.md; do \$EDITOR \"\$open\"; done"
			''|pdf)
				open=${1:-"$EDITOR"} # What to open the file with.
				run="select open in *.${1:-md}; do $open \"\$open\"; done" # Funky eval string
				if [ -n "$term" ]
				then
					$term env -C "$wdir" bash -c "$run" # Run in term
				else
					eval "$run" # eval is evil
					eval "$run" # eval is evil, but rn i need it :p
				fi
				;;
			*)