forked from SMPyBandits/SMPyBandits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
symlinks.sh
executable file
·37 lines (34 loc) · 1.25 KB
/
symlinks.sh
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
#!/usr/bin/env /bin/bash
# Symlink every .html as fake .ipynb files in the output notebook directory of the documentation
cd _build/html/notebooks/ 2>/dev/null
cd ../_build/html/notebooks/ 2>/dev/null
pwd
function softsymlinkit() {
html="$1"
ipynb="${1%.html}.ipynb"
echo -e "\nHTML file = $html and Jupyter notebook link = $ipynb"
ls -larth "$html"
if [ -f "$html" ]; then
if [ -f "$ipynb" ]; then
if [ ! -L "$ipynb" ]; then
echo -e "${red}Error${white}: $ipynb already exist but it is not a previous symlink."
else
echo -e "${magenta}Warning${white}: $ipynb already exist but it is already a symlink... Forcing to update it"
echo -e "${green}Symlinking${white}: $ipynb ----> $html"
echo -e ln -s -f "$html" "$ipynb"
# read # DEBUG
ln -s -f "$html" "$(basename "$ipynb")"
fi
else
echo -e "${green}Symlinking${white}: $ipynb ----> $html"
echo -e ln -s "$html" "$ipynb"
# read # DEBUG
ln -s "$html" "$(basename "$ipynb")"
fi
else
echo -e "${red}Error${white}: $html does not exist."
fi
}
for i in *.html; do
softsymlinkit "$i"
done