ksh 键绑定陷阱

ksh 键绑定陷阱

我正在尝试遵循此代码示例

http://www.kornshell.com/examples/keybind

# Example from page 98
typeset -A Keytable
trap 'eval "${Keytable[${.sh.edchar}]}"' KEYBD
function keybind # key [action]
{
    typeset key=$(print -f "%q" "$2")
    case $# in
    2)      Keytable[$1]=' .sh.edchar=${.sh.edmode}'"$key"
            ;;
    1)      unset Keytable[$1]
            ;;
    *)      print -u2 "Usage: $0 key [action]"
            return 2 # usage errors return 2 by default
            ;;
    esac
}

还有这个:https://cs.nyu.edu/courses/fall01/G22.2245-001/syll/lect7.pdf

如果我按 Ctrl+C 终端线会清除,按 Ctrl+LI 会看到 ^L

我想让 Ctrl+L 绑定到清除命令。

如何设置上面的 KEYBD 功能来捕获此命令并清除终端?

相关内容