【发布时间】:2018-05-21 13:36:52
【问题描述】:
根据this source,可以对游标进行以下操作:
- Position the Cursor:
\033[<L>;<C>H
Or
\033[<L>;<C>f
puts the cursor at line L and column C.
- Move the cursor up N lines:
\033[<N>A
- Move the cursor down N lines:
\033[<N>B
- Move the cursor forward N columns:
\033[<N>C
- Move the cursor backward N columns:
\033[<N>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
因此您可以使用\033[s 保存光标位置,然后使用\033[u 恢复它。但是如果我想保存几个光标位置呢?
例如,假设我想保存两个光标位置,然后恢复它们。价值观会被抹去吗?所以我的问题是:有没有办法,使用 ANSI 转义序列或不,保存几个光标位置以便以后在 bash 中恢复它们?
【问题讨论】:
标签: bash ansi cursor-position