@@ -8,13 +8,19 @@ import (
8
8
"log"
9
9
)
10
10
11
+ var i int
12
+
11
13
func eval (expr string ) string {
12
- err := ioutil .WriteFile ("/Users/osnr/t/tabs/last-focused/evals/eval.js" , []byte (expr ), 0755 )
14
+ // FIXME: these need to be unique across runs
15
+ // (or just fix the truncate bug, whatever it is)
16
+ evalpath := fmt .Sprintf ("/Users/osnr/t/tabs/last-focused/evals/eval%d.js" , i )
17
+ err := ioutil .WriteFile (evalpath , []byte (expr ), 0755 )
18
+ i = i + 1
13
19
if err != nil {
14
20
fmt .Printf ("Unable to write file: %v" , err )
15
21
}
16
22
17
- dat , err := ioutil .ReadFile ("/Users/osnr/t/tabs/last-focused/evals/eval.js .result" )
23
+ dat , err := ioutil .ReadFile (evalpath + " .result" )
18
24
fmt .Printf ("[%s]" , dat )
19
25
return string (dat )
20
26
}
@@ -28,8 +34,9 @@ func url() string {
28
34
func main () {
29
35
ssh .Handle (func (s ssh.Session ) {
30
36
for {
37
+ io .WriteString (s , "\u001b [32m" )
31
38
io .WriteString (s , url ())
32
- io .WriteString (s , "> " )
39
+ io .WriteString (s , "\u001b [0m > " )
33
40
34
41
line := ""
35
42
for {
@@ -44,6 +51,10 @@ func main() {
44
51
s .Write ([]byte {'\n' })
45
52
break
46
53
}
54
+ // FIXME: this doesn't work
55
+ if ch [0 ] == byte ('\b' ) {
56
+ line = line [:len (line )- 1 ]
57
+ }
47
58
}
48
59
fmt .Printf ("Read" )
49
60
io .WriteString (s , string (eval (line )))
0 commit comments