forked from takluyver/bash_kernel
-
Notifications
You must be signed in to change notification settings - Fork 5
/
JWLS.sh
executable file
·67 lines (37 loc) · 1.62 KB
/
JWLS.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
#!/bin/bash
clear
mkdir JWLSout 2>/dev/null
function finish {
rm -r JWLSout
}
rm -r /tmp/JWLS 2>/dev/null
mkdir /tmp/JWLS 2>/dev/null
mkfifo /tmp/JWLS/wlin.fifo
touch /tmp/JWLS/wlout.txt
tail -f /tmp/JWLS/wlin.fifo | wolframscript -c '
"______________________________________________________________________"
nbAddrF := ReadString@"!jupyter notebook list"~
StringCases~Shortest["http://"~~__~~"/"]//
If[# == {}
,(Print["\n$:"<>#]; Run@#)& @"jupyter notebook &";
Pause@1; nbAddrF
,Print["\n~: "<>First@#]; First@#<>"files/"
]&
$nbAddr = nbAddrF
______________________________________________________________________
show@g_Image := "echo "<>$nbAddr<>Export["JWLSout/out.png",g,"PNG"]//
(Run@#; Return@Last@StringSplit@#)&
show@g_ := "echo "<>$nbAddr<>Export["JWLSout/out.pdf",g,"PDF"]//
(Run@#; Return@Last@StringSplit@#)&
show@g_Graphics3D := "wolframplayer -nosplash "<>Export["JWLSout/out.nb",g] // Run
Protect@show
$PrePrint = Shallow[ #,{Infinity,12}]&;
______________________________________________________________________
SetOptions[$Output,FormatType->OutputForm, PageWidth->120]
ghostRun := (Run@#; $Line = $Line-1; Return[])&
emptylogF := ghostRun["> "<>Streams[][[1,1]]]
catoutF := ghostRun["cat "<>Streams[][[1,1]]<>" > /tmp/JWLS/wlout.txt"]
______________________________________________________________________
$Line = 0
Dialog[]'
trap finish EXIT