Skip to content

Commit 29f0ffe

Browse files
committed
color prompt, make evalN.js unique
1 parent e2f76ab commit 29f0ffe

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tabssh.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ import (
88
"log"
99
)
1010

11+
var i int
12+
1113
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
1319
if err != nil {
1420
fmt.Printf("Unable to write file: %v", err)
1521
}
1622

17-
dat, err := ioutil.ReadFile("/Users/osnr/t/tabs/last-focused/evals/eval.js.result")
23+
dat, err := ioutil.ReadFile(evalpath + ".result")
1824
fmt.Printf("[%s]", dat)
1925
return string(dat)
2026
}
@@ -28,8 +34,9 @@ func url() string {
2834
func main() {
2935
ssh.Handle(func(s ssh.Session) {
3036
for {
37+
io.WriteString(s, "\u001b[32m")
3138
io.WriteString(s, url())
32-
io.WriteString(s, "> ")
39+
io.WriteString(s, "\u001b[0m> ")
3340

3441
line := ""
3542
for {
@@ -44,6 +51,10 @@ func main() {
4451
s.Write([]byte{'\n'})
4552
break
4653
}
54+
// FIXME: this doesn't work
55+
if ch[0] == byte('\b') {
56+
line = line[:len(line)-1]
57+
}
4758
}
4859
fmt.Printf("Read")
4960
io.WriteString(s, string(eval(line)))

0 commit comments

Comments
 (0)