2021-01-08 06:52:20 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
|
|
|
|
|
|
|
sp = SpawnedProc()
|
|
|
|
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
|
|
|
sp.send,
|
|
|
|
sp.sendline,
|
|
|
|
sp.sleep,
|
|
|
|
sp.expect_prompt,
|
|
|
|
sp.expect_re,
|
|
|
|
sp.expect_str,
|
|
|
|
)
|
|
|
|
expect_prompt()
|
|
|
|
|
2024-04-13 14:00:13 +08:00
|
|
|
sendline("set -g fish_autosuggestion_enabled 0")
|
2024-06-03 05:17:23 +08:00
|
|
|
expect_prompt()
|
2024-04-13 14:00:13 +08:00
|
|
|
sendline("bind U,n,d,o undo; bind R,e,d,o redo")
|
2021-01-08 06:52:20 +08:00
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
send("echo word")
|
|
|
|
expect_str("echo word")
|
|
|
|
|
|
|
|
send("Undo")
|
2024-03-02 14:58:01 +08:00
|
|
|
expect_str("echo")
|
2021-01-08 06:52:20 +08:00
|
|
|
|
2024-04-13 14:12:21 +08:00
|
|
|
send("Redo\r")
|
2024-06-03 05:17:23 +08:00
|
|
|
expect_prompt("echo word")
|
2024-04-13 14:12:21 +08:00
|
|
|
|
|
|
|
sendline("bind x begin-undo-group 'commandline -i \"+ \"' 'commandline -i 3' end-undo-group")
|
2024-06-03 05:17:23 +08:00
|
|
|
expect_prompt()
|
2024-04-13 14:12:21 +08:00
|
|
|
send("math 2 x\r")
|
|
|
|
expect_prompt("5")
|
|
|
|
|
|
|
|
send("math 4x")
|
|
|
|
send("Undo1\r")
|
|
|
|
expect_prompt("41")
|
|
|
|
|
|
|
|
send("math 5 x")
|
|
|
|
send("\x02") # c-b, moving before the 3
|
|
|
|
send("Undo")
|
|
|
|
send("Redo")
|
|
|
|
send("9\r") # 5 + 93
|
|
|
|
expect_prompt("98")
|