Repository navigation
Expand file tree
/
Copy pathresearch_mac.sh
More file actions
executable file
·220 lines (179 loc) · 5.88 KB
/
Copy pathresearch_mac.sh
File metadata and controls
executable file
·220 lines (179 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/usr/bin/env bash
set -euo pipefail
echo "==> Academic research tools setup"
# --- Homebrew check ---
if ! command -v brew &>/dev/null; then
echo "Error: Homebrew not found. Run mac.sh first."
exit 1
fi
# --- Brew formulae ---
BREW_PACKAGES=(
# LaTeX
mactex # full TeX distribution (pdflatex, bibtex, tlmgr, etc.)
latexmk # auto-build LaTeX docs (handles re-runs for refs/bibtex)
# Document conversion
pandoc # convert between formats (md → pdf, latex → docx, etc.)
pandoc-crossref # cross-references for pandoc (figures, tables, equations)
# PDF tools
poppler # PDF utilities (pdftotext, pdfinfo, pdfunite, pdfseparate)
# Figures & media
imagemagick # image conversion and manipulation (convert, mogrify)
gnuplot # plotting from terminal/scripts
ffmpeg # video/audio processing (for multimedia research)
)
echo "==> Installing brew formulae..."
INSTALLED=$(brew list --formula -1)
for pkg in "${BREW_PACKAGES[@]}"; do
if echo "$INSTALLED" | grep -qx "$pkg"; then
echo " $pkg already installed, skipping."
else
echo " Installing $pkg..."
brew install "$pkg" 2>/dev/null || true
fi
done
# --- Brew casks ---
CASK_PACKAGES=(
zotero # reference manager (integrates with Word, LibreOffice, Google Docs)
skim # lightweight PDF viewer with LaTeX sync (SyncTeX support)
)
echo "==> Installing cask apps..."
INSTALLED_CASKS=$(brew list --cask -1)
for pkg in "${CASK_PACKAGES[@]}"; do
if echo "$INSTALLED_CASKS" | grep -qx "$pkg"; then
echo " $pkg already installed, skipping."
else
echo " Installing $pkg..."
brew install --cask "$pkg" 2>/dev/null || true
fi
done
# --- Pip packages ---
echo "==> Installing pip packages..."
pip install --quiet arxiv-dl --break-system-packages 2>/dev/null || pip3 install --quiet arxiv-dl --break-system-packages 2>/dev/null || true
# Set default download directory for arxiv-dl
mkdir -p "$HOME/.arxiv"
export ARXIV_DL_DIR="$HOME/.arxiv"
# --- paper-init function ---
echo "==> Installing paper-init command..."
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
PAPER_INIT_DIR="$DOTFILES_DIR/templates/paper"
mkdir -p "$PAPER_INIT_DIR"
# Style file: clean, minimal style for proposals and lit reviews
cat > "$PAPER_INIT_DIR/quickpaper.sty" << 'STY'
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{quickpaper}[Quick paper style for proposals and lit reviews]
% --- Page layout ---
\RequirePackage[margin=1in]{geometry}
\RequirePackage{setspace}
\onehalfspacing
% --- Typography ---
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}
\RequirePackage{microtype}
% --- Math ---
\RequirePackage{amsmath,amssymb,amsthm}
% --- Figures & tables ---
\RequirePackage{graphicx}
\RequirePackage{booktabs}
\RequirePackage{caption}
\captionsetup{font=small,labelfont=bf}
% --- References & links ---
\RequirePackage[colorlinks=true,linkcolor=blue!70!black,citecolor=green!50!black,urlcolor=blue!70!black]{hyperref}
\RequirePackage[numbers,sort&compress]{natbib}
% --- Section formatting ---
\RequirePackage{titlesec}
\titleformat{\section}{\large\bfseries}{\thesection.}{0.5em}{}
\titleformat{\subsection}{\normalsize\bfseries}{\thesubsection.}{0.5em}{}
% --- Useful shortcuts ---
\newcommand{\eg}{e.g.\@\xspace}
\newcommand{\ie}{i.e.\@\xspace}
\newcommand{\etal}{et~al.\@\xspace}
\newcommand{\cf}{cf.\@\xspace}
\RequirePackage{xspace}
% --- Theorem environments ---
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{definition}[theorem]{Definition}
% --- Todo notes (remove for final) ---
\RequirePackage[textsize=small,color=yellow!30]{todonotes}
\newcommand{\TODO}[1]{\todo[inline]{#1}}
STY
# Main tex template
cat > "$PAPER_INIT_DIR/main.tex" << 'TEX'
\documentclass[11pt]{article}
\usepackage{quickpaper}
\title{TITLE}
\author{AUTHOR}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
Your abstract here.
\end{abstract}
\section{Introduction}
\label{sec:intro}
\section{Related Work}
\label{sec:related}
\section{Method}
\label{sec:method}
\section{Experiments}
\label{sec:experiments}
\section{Conclusion}
\label{sec:conclusion}
\bibliographystyle{plainnat}
\bibliography{references}
\end{document}
TEX
# Bib file with example entry
cat > "$PAPER_INIT_DIR/references.bib" << 'BIB'
@article{example2024,
author = {Last, First and Other, Author},
title = {Example Paper Title},
journal = {arXiv preprint arXiv:2401.00000},
year = {2024},
}
BIB
# Latexmk config
cat > "$PAPER_INIT_DIR/.latexmkrc" << 'LATEXMKRC'
$pdf_mode = 1;
$pdflatex = 'pdflatex -interaction=nonstopmode -synctex=1 %O %S';
$bibtex_use = 2;
$clean_ext = 'synctex.gz run.xml tex.bak bbl blg';
LATEXMKRC
# paper-init shell function
PAPER_INIT_FUNC='
# Initialize a new paper from template
paper-init() {
local dir="${1:-.}"
local template_dir="TEMPLATE_DIR"
if [ ! -d "$template_dir" ]; then
echo "Error: Template not found at $template_dir. Run research_mac.sh first."
return 1
fi
mkdir -p "$dir"
cp "$template_dir/quickpaper.sty" "$dir/"
cp "$template_dir/main.tex" "$dir/"
cp "$template_dir/references.bib" "$dir/"
cp "$template_dir/.latexmkrc" "$dir/"
mkdir -p "$dir/figures"
echo "Paper initialized in $dir/"
echo " cd $dir && latexmk # build PDF"
}
'
PAPER_INIT_FUNC="${PAPER_INIT_FUNC//TEMPLATE_DIR/$PAPER_INIT_DIR}"
# Add to profile if not already present
PROFILE_SOURCE="$DOTFILES_DIR/profile.sh"
if ! grep -qF "paper-init" "$PROFILE_SOURCE" 2>/dev/null; then
echo "$PAPER_INIT_FUNC" >> "$PROFILE_SOURCE"
echo " paper-init added to profile."
else
echo " paper-init already in profile."
fi
echo ""
echo "==> Done! Research tools installed."
echo ""
echo "Quick start:"
echo " latexmk -pdf paper.tex # build LaTeX to PDF"
echo " pandoc paper.md -o paper.pdf # markdown to PDF"
echo " pdftotext paper.pdf # extract text from PDF"
echo " paper 2301.07041 # download arxiv paper by ID"