Gil*_*il' 25
preexec () {
clear
}
preexec_invoke_exec () {
[ -n "$COMP_LINE" ] && return # do nothing if completing
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # don't cause a preexec for $PROMPT_COMMAND
local this_command=`history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g"`; # obtain the command from the history, removing the history number at the beginning
preexec "$this_command"
}
trap 'preexec_invoke_exec' DEBUG
Run Code Online (Sandbox Code Playgroud)
bind 'RETURN: "\e[1~clear; \e[4~\n"'
Run Code Online (Sandbox Code Playgroud)
之后,每次按下return而不是只写\n它都会移动到行首,输入文本clear;,然后移动到末尾并按\n预期输入。