diff options
| -rwxr-xr-x | misc/hwtexedit | 49 | ||||
| -rwxr-xr-x | misc/pdfautocompile | 39 | 
2 files changed, 49 insertions, 39 deletions
diff --git a/misc/hwtexedit b/misc/hwtexedit new file mode 100755 index 0000000..262d10b --- /dev/null +++ b/misc/hwtexedit @@ -0,0 +1,49 @@ +#!/bin/sh +dir=~/docs/school + +files="$(find $dir -name \*.tex -printf "%T@ %p\n" | sort -nr | cut -d' ' -f 2-)" + +echo "$files" | awk ' +function printcol(c1, c2, c3) { printf "%-12s %-32s %s\n", c1, c2, c3 } +BEGIN { +	printcol("   class:", "containing dir:", "file:") +	fn = 1 +} +{ +	tf = c = cf = $0 +	sub(/.*\//, "", tf) +	sub("'$dir'/", "", c) +	sub(/\/.*/, "", c) +	sub("'$dir'/"c"/", "", cf) +	sub("/"tf, "", cf) +	printcol(fn": "c, cf, tf) +	fn++ +} +' +read -p "Choose file number: " filenum +file="$(echo "$files" | head -$filenum | tail -1)" +dir="$(echo "$file" | sed 's/\(\/.*\)\/.*/\1/')" + +cd "$dir" + +st -e $EDITOR "$file" & +echo "$file" | entr pdflatex -output-directory "$dir" "$file" || echo "entr or LaTeX is not installed!" & +zathura "$(echo "$file" | sed 's/.tex$/.pdf/')" & + +#listfiles() { +#	pids=$(xdotool search --class "Vim") +#	for pid in $pids; do +#		names="$(xdotool getwindowname $pid | grep '\.tex')\n$names" +#		#$openfiles="$(echo "$name" | cut -d' ' -f1)\n$openfiles" +#		#$openfilepaths="$(echo "$name" | awk -F'[()]' '{ print $2 }')\n$openfiles" +#	done +#	#file="$(echo $openfiles | grep "^$1")" +#	[ -z "$file" ] \ +#		&& interactiveopt "$(echo $openfiles | sort -bu | tail +2)" "Which file to autocompile? " 1 \ +#		&& file="$opt" +#} +# +#[ -e "$1" ] && file="$1" || listfiles +# +#echo "$file" | entr pdflatex "$file" || echo "entr or LaTeX is not installed!" + diff --git a/misc/pdfautocompile b/misc/pdfautocompile deleted file mode 100755 index 3c0d8f4..0000000 --- a/misc/pdfautocompile +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -interactiveopt() { -	# Usage: interactiveopt "options" "prompt" "maxopts (if unset than equal to inf)" "col" -	# Purpose: give the user a numbered list of options. User can specify multiple choices. User can specify either the number or the name of the option. -	# Output: saved in variable "opt" -	unset opt # This won't be set if using recursion, do it in a while loop instead -	while [ -z $opt ] 2>/dev/null; do -		# Column option -		[ -n "$4" ] && [ "$4" = "col" ] \ -			&& echo "$1" | nl -s': ' | column \ -			|| echo "$1" | nl -s': ' -		# Parse user input -		read -p "$2" choices \ -			&& choices="$(echo $choices | cut -d' ' -f1-$3)" -		for choice in $choices; do -			case "$choice" in -				[0-9]*)	opt="$(echo "$1" | head -"$(echo $choice | tr -cd '[:digit:]')" | tail -1) $opt"	;; -				*) 	opt="$(echo "$1" | grep "^$choice$" 2>/dev/null) $opt"					;; -			esac || ( echo "Invalid option \"$choice\"" && undet opt && break ) # Why wont this unset opt or break??????? -		done -	done -} - -listfiles() { -	pids=$(xdotool search --class "Vim") -	for pid in $pids; do -		names="$(xdotool getwindowname $pid | grep '\.tex')\n$names" -		#$openfiles="$(echo "$name" | cut -d' ' -f1)\n$openfiles" -		#$openfilepaths="$(echo "$name" | awk -F'[()]' '{ print $2 }')\n$openfiles" -	done -	#file="$(echo $openfiles | grep "^$1")" -	[ -z "$file" ] \ -		&& interactiveopt "$(echo $openfiles | sort -bu | tail +2)" "Which file to autocompile? " 1 \ -		&& file="$opt" -} - -[ -e "$1" ] && file="$1" || listfiles - -echo "$file" | entr pdflatex "$file" || echo "entr or LaTeX is not installed!"  | 
