-
-
Save mdelhoneux/d8cf609f9c11e647573f396dffd33830 to your computer and use it in GitHub Desktop.
Tweaked version of de Lhoneux's thesis progress script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Assumes PDF and tex filepath differ only in the extension | |
| # | |
| # Usage: | |
| # thesis_progress.sh [FILENAME [TARGET_PAGECOUNT]] | |
| # | |
| # FILENAME is your thesis PDF (def: thesis.pdf) | |
| # TARGET_PAGECOUNT is the number of pages you want to write (def: 180) | |
| # | |
| # Written by Miryam de Lhoneux, March 2019 | |
| # Command-line args and documentation added by Dave Howcroft, May 2019 | |
| THESIS_PDF=${1:-thesis.pdf} | |
| TARGET_PAGECOUNT=${2:-180} | |
| # For debugging | |
| #echo ${THESIS_PDF} | |
| #echo ${TARGET_PAGECOUNT} | |
| count_tex(){ | |
| detex $1 | wc -w | tr -d [:space:] | |
| } | |
| echo " ----------------------------------" | |
| n_pages=$(pdfinfo ${THESIS_PDF} |grep Pages |awk '{print $NF}') | |
| n_pages=$(( $n_pages + 0)) | |
| prog_done=$(bc <<< "scale=2; $n_pages/${TARGET_PAGECOUNT}") | |
| prog_bars=$(echo "$prog_done*10" | bc) | |
| if (( $(echo "$prog_bars >= 1" |bc -l) )) | |
| then | |
| prog_bars=${prog_bars%.*} | |
| else | |
| prog_bars=0 | |
| fi | |
| prog_dots=$(( 10 - ${prog_bars} )) | |
| percentage_done=$(echo "$prog_done*100" |bc) | |
| echo "| $n_pages/${TARGET_PAGECOUNT} pages done - $percentage_done% done |" | |
| echo -n "| ["; for ((i=1; i<=$prog_bars; i++)); do echo -n '|'; done ;for ((i=1; i<=$prog_dots; i++)); do echo -n '.'; done | |
| echo "] |" | |
| words_written=$(count_tex ${THESIS_PDF::-4}.tex) | |
| echo "| $words_written words written in total |" | |
| echo " ----------------------------------" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment