How do you edit existing text (and move the cursor around) in the terminal?

后端 未结 2 484
南旧
南旧 2020-12-12 19:50

I saw this demo once that printed out a paragraph of text (like you\'d get when typing some-command --help), and it then jumped back up to a couple keywords in

2条回答
  •  旧巷少年郎
    2020-12-12 20:27

    Finally found that "demo":

    • https://github.com/asyncly/cdir/blob/223fe0039fade4fad2bb08c2f7affac3bdcf2f89/cdir.js#L24
    • http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html
    • http://ascii-table.com/ansi-escape-sequences-vt-100.php

    • Position the Cursor: \033[;H or \033[;f (puts the cursor at line L and column C)

    • Move the cursor up N lines: \033[A
    • Move the cursor down N lines: \033[B
    • Move the cursor forward N columns: \033[C
    • Move the cursor backward N columns: \033[D
    • Clear the screen, move to (0,0): \033[2J
    • Erase to end of line: \033[K
    • Save cursor position: \033[s
    • Restore cursor position: \033[u

提交回复
热议问题