├── ix ├── pdf2doi ├── screencast-select ├── doi2bib ├── notetags ├── notate └── pdf /ix: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: Conner McDaniel 4 | # https://github.com/connermcd/bin 5 | # MIT license 6 | 7 | curl -s -n -F 'f:1=<-' http://ix.io 8 | -------------------------------------------------------------------------------- /pdf2doi: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: Conner McDaniel 4 | # https://github.com/connermcd/bin 5 | # MIT license 6 | 7 | set -e 8 | 9 | pdftotext "$1" - | grep -oP "\b(10[.][0-9]{4,}(?:[.][0-9]+)*/(?:(?![\"&\'<>])\S)+)\b" | head -n 1 10 | -------------------------------------------------------------------------------- /screencast-select: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: Conner McDaniel 4 | # https://github.com/connermcd/bin 5 | # MIT license 6 | 7 | set -e 8 | 9 | selection=$(xrectsel) 10 | ffmpeg -f x11grab -r 30 -s $(echo $selection | cut -f1 -d' ' ) -i :0.0$(echo $selection | cut -f2 -d' ' ) -vcodec libx264 -preset ultrafast -crf 0 -y screencast-select.mp4 11 | -------------------------------------------------------------------------------- /doi2bib: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: Conner McDaniel 4 | # https://github.com/connermcd/bin 5 | # MIT license 6 | 7 | set -e 8 | 9 | result= 10 | i= 11 | while [[ $i < 10 && "$result" != *"author = "* ]]; do 12 | result=$(curl -s "http://api.crossref.org/works/$1/transform/application/x-bibtex") 13 | i=$(( $i + 1 )) 14 | done 15 | echo "$result" 16 | -------------------------------------------------------------------------------- /notetags: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: Conner McDaniel 4 | # https://github.com/connermcd/bin 5 | # MIT license 6 | 7 | set -e 8 | 9 | cd $HOME/Documents/Notes/ 10 | 11 | [[ -f tags ]] && rm tags 12 | grep --exclude="*.bib" -r "tags = {" * | while read line; do 13 | file=$(echo "$line" | cut -d: -f1) 14 | unparsed_tags=$(echo "$line" | cut -d: -f2) 15 | tags=$(echo $unparsed_tags | sed -e "s/tags = {//g" -e "s/,\|}//g") 16 | for tag in $tags; do 17 | echo "$tag $file /^$unparsed_tags$/;" >> tags 18 | done 19 | done 20 | 21 | [[ -f global.bib ]] && rm global.bib 22 | pcregrep -r -h -M -I --exclude-dir=img --exclude=".*pdf" "^@(\n|.)*~~~" . > global.bib 23 | -------------------------------------------------------------------------------- /notate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: Conner McDaniel 4 | # https://github.com/connermcd/bin 5 | # MIT license 6 | 7 | set -e 8 | 9 | pdf="$1" 10 | doi="$(pdf2doi ${1})" 11 | bib=$(curl -s "http://api.crossref.org/works/$doi/transform/application/x-bibtex") 12 | title=$(echo "$bib" | sed -n '1p' | cut -d{ -f2 | sed 's/,//') 13 | file_name= 14 | 15 | make_file() { 16 | new_pdf="$(dirname $pdf)/$1.pdf" 17 | [[ ! -f "$new_pdf" ]] && mv "$pdf" "$new_pdf" 18 | bib=$(echo "$bib" | sed "1a\\\tpdf = {$new_pdf},") 19 | cat >"$file_name" < /dev/null 52 | ABS_PATH="$PWD" 53 | popd > /dev/null 54 | INPUT="$ABS_PATH/$INPUT_BASE" 55 | 56 | if [[ "$OUTPUT" != "$ABS_PATH" && `dirname "$OUTPUT"` != "$ABS_PATH" ]]; then 57 | DELETE=true 58 | fi 59 | 60 | FILETYPE=`echo "$INPUT_BASE" | awk -F . '{print tolower($NF)}'` 61 | if [[ $FILETYPE == "pdf" ]]; then 62 | echo "$INPUT is already a PDF! Skipping..." 63 | continue 64 | elif [[ -d "$INPUT" ]]; then 65 | echo "$INPUT is a directory! Skipping..." 66 | continue 67 | elif [[ ! -e "$INPUT" ]]; then 68 | echo "$INPUT does not exist! Skipping..." 69 | continue 70 | fi 71 | 72 | if [[ -n "$OUTPUT" && -d "$OUTPUT" ]]; then 73 | INPUT_COPY="$OUTPUT/$INPUT_BASE" 74 | if [[ $DELETE ]]; then 75 | cp "$INPUT" "$INPUT_COPY" 76 | fi 77 | INPUT="$INPUT_COPY" 78 | PDF="${INPUT%%.$FILETYPE}.pdf" 79 | elif [ -n "$OUTPUT" ]; then 80 | INPUT_COPY="${OUTPUT%%.pdf}.$FILETYPE" 81 | if [[ $DELETE ]]; then 82 | cp "$INPUT" "$INPUT_COPY" 83 | fi 84 | INPUT="$INPUT_COPY" 85 | PDF="$OUTPUT" 86 | else 87 | PDF="${INPUT%%.$FILETYPE}.pdf" 88 | fi 89 | 90 | DIR=`dirname "$INPUT"` 91 | INPUT_BASE=`basename "$INPUT"` 92 | pushd "$DIR" > /dev/null 93 | ABS_PATH="$PWD" 94 | popd > /dev/null 95 | INPUT="$ABS_PATH/$INPUT_BASE" 96 | 97 | if [[ -e "$PDF" ]]; then 98 | read -p "$PDF already exists. Overwrite? (y/Y/n/N)" 99 | if [[ "$REPLY" != "y" && "$REPLY" != "Y" ]]; then 100 | if [[ -e "$INPUT_COPY" && $DELETE ]]; then 101 | rm "$INPUT_COPY" 102 | fi 103 | continue 104 | else 105 | rm "$PDF" 106 | fi 107 | fi 108 | 109 | /usr/bin/soffice --invisible "macro:///Standard.Module1.ConvertToPDF($INPUT)" 110 | if [[ -e "$INPUT_COPY" && $DELETE ]]; then 111 | rm "$INPUT_COPY" 112 | fi 113 | if [[ -e "$PDF" ]]; then 114 | echo "$INPUT successfully converted!" 115 | if [ -n "$EXECUTE" ]; then 116 | open "$PDF" 117 | fi 118 | else 119 | echo "There was a problem converting your file: $INPUT" 120 | fi 121 | done 122 | --------------------------------------------------------------------------------