CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Difference between
modified post 804 by luc on Sat 23rd Oct 15:33 and
original post 803 by luc on Sat 23rd Oct 14:57
Show old version | new version | both versions

    
11
#!/bin/bash
22
#
33
#A script to compile .tex files to .pdf (and optionally, .rtf or .html)
44
#with bibliography support.
55
#
66
#Depends on: latex, bibtex, dvips, ps2pdf,
77
#Suggests: latex2rtf, latex2html, evince (or any other pdf viewer)
88
#
99
#Written by: J.Barney
1010
#Last updated: 22.10.10
1212
#Save working directory to come back to
1313
OLDDIR="`pwd`"
1515
#Check directory
1616
echo ""
1717
read -p "Is you latex project in the current directory? y|[n]" switchdir
1818
echo ""
2020
#Select directory besides the working one
21-
if [ "$switchdir" = "n" ] || [ "$switchdir" = "N" ] || [ "$switchdir" = "no" ] || [ "$switchdir" = "No" ] || [ "$switchdir" = "" ]; then
21+
if [[ $switchdir =~ n|N|(no)|(No) ] || [[ -z $switchdir ]]; then
2222
    texdirectory=$(zenity --file-selection --directory --title="Select DIRECTORY of the .tex file");
2323
    cd "$texdirectory"
2424
fi
2626
#Optional backup
2727
read -p "Would you like to create a backup before compiling? [y]|n" backup
28-
if [ "$backup" = "y" ] || [ "$backup" = "Y" ] || [ "$backup" = "yes" ] || [ "$backup" = "Yes" ] || [ "$backup" = "" ] ; then
28+
if [[ $backup =~ y|Y|(yes)|(Yes)|(YES) ]] || [[ -z $backup ]]; then
2929
    CURDIR="`pwd`"
30-
    if [ ! -e "$CURDIR/backups" ]; then
30+
    if [[ ! -e $CURDIR/backups ]]; then
3131
        echo "Backups directory not detected, making one..."
3232
        mkdir "$CURDIR/backups"
3333
    fi
3434
    BACKUPDATE=`date +%m_%d_at_%H_%M`
3535
    cd "$CURDIR/backups"
3636
    nice tar cvpzf backup_$BACKUPDATE.tar --exclude="$CURDIR/backups" "$CURDIR/*"
3737
    cd "$CURDIR"
3838
else
3939
    echo "Warning: We are NOT making a backup!"
4040
    echo ""
4141
fi
4343
#Select .tex file
4444
#Check to see if there is only one file -- use it if so."
45-
if [ `ls *.tex | wc -l` -gt 1 ]; then
45+
if [[ `ls *.tex | wc -l` -gt 1 ]]; then
4646
    TEXLIST="`ls *.tex | sed 's/.tex$//'`"
4747
    echo "Select .tex file"
4848
    # TODO: warning this does not work with spaces in filenames!
4949
    select texfile in $TEXLIST
5050
    do
5151
        break
5252
    done
5353
    else
5454
        texfile="`ls *.tex`"
5555
        texfile="{texfile%.tex}"
5656
        echo "Using 1 found .tex file: $texfile"
5757
fi
5858
echo ""
6060
#Check for .bib
61-
if [ -e *.bib ]; then
61+
if [[ -e *.bib ]] ; then
6262
    read -p ".bib file found. Include it? [y]|n" biblio
6363
    echo ""
64-
    if [ "$biblio" = "y" ] || [ "$biblio" = "Y" ] || [ "$biblio" = "yes" ] || [ "$biblio" = "Yes" ] || [ "$biblio" = "" ]; then
64+
    if [[ $biblio =~ y|Y|(yes)|(Yes)|(YES) ]] || [[ -z $biblio ]]; then
6565
        #reset biblio for easy reuse (see further down)
6666
        biblio="yes"
6767
        #Select if more than 1 .bib file
68-
        if [ `ls *.bib | wc -l` -gt 1 ]; then
68+
        if [[ `ls *.bib | wc -l` -gt 1 ]]; then
6969
            BIBLIST="`ls *.bib | sed 's/.bib$//'`"
7070
            echo "Multiple .bibs found, select one"
7171
            # TODO: warning this does not work with spaces in filenames!
7272
            select biblioname in $BIBLIST
7373
            do
7474
                break
7575
            done
7676
            echo ""
7777
            else
7878
                biblioname="`ls *.bib`"
7979
                biblioname="{biblioname%.bib}"
8080
                echo "Using 1 found .bib file: $biblioname"
8181
                sleep 2s
8282
        fi
8383
    else
8484
        #reset biblio for easy reuse (see further down)
8585
        biblio="no"
8686
    fi
8787
fi
8989
latex "${texfile}.tex"
9090
#biblio was reset to be either "yes" or "no"
91-
if [ "$biblio" = "yes" ] ; then
91+
if [ $biblio = yes ]] ; then
9292
    bibtex "${biblioname}.bib"
9393
fi
9494
latex "${texfile}.tex"
9595
latex "${texfile}.tex"
9696
dvips "${texfile}.div"
9797
ps2pdf "${texfile}.ps" "${texfile}.pdf"
9999
echo ""
100100
echo "Compilation complete."
101101
echo ""
102102
read -p "Create .rtf version now? [y]|n" rtfnow
103-
if [ "$rtfnow" = "y" ] || [ "$rtfnow" = "Y" ] || [ "$rtfnow" = "yes" ] || [ "$rtfnow" = "Yes" ] || [ "$rtfnow" = "" ]; then
103+
if [[ $rtfnow =~ y|Y|(yes)|(Yes)|(YES) ]] || [[ -z $rtfnow ]]; then
104104
    latex2rtf "${texfile}.tex"
105105
fi
106106
echo ""
107107
read -p "Create .html version now? [y]|n" htmlnow
108-
if [ "$htmlnow" = "y" ] || [ "$htmlnow" = "Y" ] || [ "$htmlnow" = "yes" ] || [ "$htmlnow" = "Yes" ] || [ "$htmlnow" = "" ]; then
108+
if [[ $htmlnow =~ y|Y|(yes)|(Yes)|(YES) ]] || [[ -z $htmlnow ]]; then
109109
    latex2html "${texfile}.tex"
110110
fi
111111
echo ""
112112
read -p "Open .pdf now? (Y/n): " opennow
113-
if [ "$opennow" = "y" ] || [ "$opennow" = "Y" ] || [ "$opennow" = "yes" ] || [ "$opennow" = "Yes" ] || [ "$opennow" = "" ]; then
113+
if [[ $opennow =~ y|Y|(yes)|(Yes)|(YES) ]] || [[ -z $opennow ]]; then
114114
        evince "${texfile}.pdf" &
115115
fi
116116
cd "$OLDDIR"
117117
exit 0
118118
#end

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me