-
-
Notifications
You must be signed in to change notification settings - Fork 165
/
Copy pathtty.sh
executable file
·61 lines (48 loc) · 1.23 KB
/
tty.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
#!/usr/bin/env bash
#
# Usage:
# ./tty.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
# makes a file called ttyrecord. Has TIMING info.
ttyrec-demo() {
ttyrec -e demo/pyreadline.py
}
play() {
ttyplay ttyrecord
}
# makes a file called 'typescript'
script-demo() {
script -c demo/pyreadline.py "$@"
}
# TODO: Can we see how efficient it is?
show-script() {
#od -c typescript
cat typescript
}
# Conclusion: readline is smart enough not to redraw the entire line when you
# use set_completer_delims('')! So you should do that!
#
# You can see this by using -W -- it deletes stuff.
readonly FIFO=_tmp/script-fifo
record-to-fifo() {
local cmd=${1:-demo/pyreadline.py} # e.g. try zsh or bash
mkfifo $FIFO || true
script --flush --command "$cmd" $FIFO
}
# in another window. This shows control codes.
# Honestly this could use a Python version using repr().
# Recording fish is interesting. It apparently does React-like diffing.
# It optimizes the control codes when you navigate the file list.
#
# Elvish doesn't do this! It draws the whole thing each time!
play-fifo() {
cat -A $FIFO
}
# Cool program!
# https://github.com/haberman/vtparse
vtparse-fifo() {
~/git/languages/vtparse/test < $FIFO
}
"$@"