-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
170 lines (155 loc) · 5.8 KB
/
install.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
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
#
# Installation script for portable Julia with VS Code
# version 1.1 (C) 2022-2024, Petr Krysl
# Further configuration options for VS Code:
# {
# "key": "ctrl+c",
# "command": "workbench.action.terminal.copySelection",
# "when": "terminalFocus && terminalProcessSupported && terminalTextSelected"
# },
# {
# "key": "ctrl+v",
# "command": "workbench.action.terminal.paste",
# "when": "terminalFocus && terminalProcessSupported"
# },
# and make sure that this setting is an effect
# {
# "terminal.integrated.allowChords": false
# }
set -o errexit
set -o nounset
# Select the version of julia to run
MyPortableJuliaMajorVersion=1.10
MyPortableJuliaMinorVersion=.3 # can be used to also select release candidate
MyPortableJulia=julia-$MyPortableJuliaMajorVersion$MyPortableJuliaMinorVersion
# Make sure we are in the folder in which the portable Julia is installed.
if [ ! -d "$(pwd)"/assets/$MyPortableJulia ] ; then
if [ ! -f "$(pwd)"/assets/$MyPortableJulia-win64.zip ] ; then
echo "Downloading $MyPortableJulia"
curl https://julialang-s3.julialang.org/bin/winnt/x64/$MyPortableJuliaMajorVersion/$MyPortableJulia-win64.zip --output "$(pwd)"/assets/$MyPortableJulia-win64.zip
fi
cd assets
echo "Unzipping assets/$MyPortableJulia-win64.zip"
unzip -q "$(pwd)"/$MyPortableJulia-win64.zip
cd ..
else
echo "Found $MyPortableJulia"
fi
# Locate the Julia depot in the current folder.
export MyDepot="$(pwd)"/assets/.$MyPortableJulia-depot
if [ ! -d "$MyDepot" ] ; then
mkdir "$MyDepot"
else
echo "Found depot $MyDepot"
fi
export JULIA_DEPOT_PATH="$MyDepot"
# Expand the other zip files
# if [ ! -d assets/gnuplot ] ; then
# if [ ! -f ./assets/gnuplot.zip ] ; then
# echo "Downloading gnuplot"
# curl http://tmacchant33.starfree.jp/gnuplot_files/gp550-20220416-win64-mingw.zip --output ./assets/gnuplot.zip
# fi
# echo Installing gnuplot
# cd assets
# unzip -q ./gnuplot.zip
# cd ..
# fi
# Make sure we can start Julia just by referring to the program name.
export PATH="$(pwd)"/assets/$MyPortableJulia/bin:$PATH
# Make sure we can start gnuplot just by referring to the program name.
# export PATH="$(pwd)"/assets/gnuplot/bin:$PATH
# Add the Git binary
export PATH="$(pwd)"/assets/PortableGit/bin:$PATH
# Download, and instantiate the tutorial packages, in order to bring Julia depot up-to-date
# if [ ! -d JuliaTutorial ] ; then
# echo "Activating/instantiating a package"
# for n in JuliaTutorial
# do
# if [ ! -d $n ] ; then
# echo "Activating and instantiating $n"
# git clone https://github.com/PetrKryslUCSD/$n.git
# fi
# cd $n
# julia -e 'using Pkg; Pkg.activate("."); Pkg.instantiate(); Pkg.precompile(); exit()'
# cd ..
# done
# fi
# Make sure the Julia REPL when started activates/instantiates
if [ ! -f "$MyDepot"/config/startup.jl ] ; then
if [ ! -d "$MyDepot"/config ] ; then
mkdir "$MyDepot"/config
fi
touch "$MyDepot"/config/startup.jl
# Make sure Revise, JuliaFormatter are present in the default environment
julia -E 'import Pkg; Pkg.add("Revise")'
julia -E 'import Pkg; Pkg.add("JuliaFormatter")'
cat<<EOF >> "$MyDepot/config/startup.jl"
using Pkg
# Disable updating registry on add (still runs on up), as it is slow
Pkg.UPDATED_REGISTRY_THIS_SESSION[] = true
# The below would only be useful when not using VS Code: running REPL in VS Code does it automatically
# Globally useful packages
# import Pkg; Pkg.add("Revise")
# import Pkg; Pkg.add("JuliaFormatter")
# Setup global packages
# atreplinit() do repl
# try
# @eval using Revise
# catch err
# println("Error starting Revise: \$err")
# end
# try
# @eval using JuliaFormatter
# catch err
# println("Error starting JuliaFormatter: \$err")
# end
# end
# Is this a project environment?
# if isfile("Project.toml") && isfile("Manifest.toml")
# Pkg.activate(".")
# Pkg.instantiate()
# end
# Better format for floats
using Printf
Base.show(io::IO, f::Float64) = @printf(io, "%1.5e", f)
Base.show(io::IO, f::Float32) = @printf(io, "%1.5e", f)
Base.show(io::IO, f::Float16) = @printf(io, "%1.5e", f)
EOF
fi
if [ ! -x "$(pwd)"/assets/VSCode/Code ] ; then
VSCodeVersion="VSCode.zip"
if [ ! -d assets/VSCode ] ; then
mkdir assets/VSCode
fi
if [ ! -f assets/"$VSCodeVersion" ] ; then
echo "Downloading VSCode "
curl "https://update.code.visualstudio.com/latest/win32-x64-archive/stable" --output assets/vscode.redirect
download_link=$(cat assets/vscode.redirect | cut -d" " -f4)
curl "$download_link" --output assets/"$VSCodeVersion"
fi
echo "Expanding $VSCodeVersion"
unzip -q "assets/$VSCodeVersion" -d assets/VSCode
# unzip -q "assets/data.zip" -d assets/
# mv assets/data assets/VSCode
else
echo "Found VSCode"
fi
# Install required extensions
if [ ! -f assets/firsttimedone ] ; then
if [ ! -d assets/VSCode/data ] ; then
mkdir assets/VSCode/data
fi
assets/VSCode/bin/code --install-extension alefragnani.Bookmarks --force
assets/VSCode/bin/code --install-extension julialang.language-julia --force
assets/VSCode/bin/code --install-extension kaiwood.center-editor-window --force
assets/VSCode/bin/code --install-extension stkb.rewrap --force
assets/VSCode/bin/code --install-extension yeannylam.recenter-top-bottom --force
assets/VSCode/bin/code --install-extension nemesv.copy-file-name --force
assets/VSCode/bin/code --install-extension PKief.material-icon-theme --force
assets/VSCode/bin/code --install-extension johnpapa.vscode-peacock --force
assets/VSCode/bin/code --install-extension chunsen.bracket-select --force
touch assets/firsttimedone
fi
# Start VS Code
echo "Starting editor"
assets/VSCode/Code