2016-04-14 02:46:18 +00:00
|
|
|
# This is meant to be bound to something like \cC.
|
|
|
|
function __fish_cancel_commandline
|
2018-10-15 18:32:59 +00:00
|
|
|
# Close the pager if it's open (#4298)
|
|
|
|
commandline -f cancel
|
|
|
|
|
2016-04-14 02:46:18 +00:00
|
|
|
set -l cmd (commandline)
|
|
|
|
if test -n "$cmd"
|
|
|
|
commandline -C 1000000
|
2017-07-04 20:23:26 +00:00
|
|
|
if set -q fish_color_cancel
|
|
|
|
echo -ns (set_color $fish_color_cancel) "^C" (set_color normal)
|
|
|
|
else
|
|
|
|
echo -ns "^C"
|
|
|
|
end
|
2016-12-31 14:12:05 +00:00
|
|
|
if command -sq tput
|
2017-04-11 03:28:26 +00:00
|
|
|
# Clear to EOL (to erase any autosuggestion).
|
|
|
|
echo -n (tput el; or tput ce)
|
2016-09-01 14:30:50 +00:00
|
|
|
end
|
2016-04-14 02:46:18 +00:00
|
|
|
for i in (seq (commandline -L))
|
|
|
|
echo ""
|
|
|
|
end
|
|
|
|
commandline ""
|
2019-07-14 16:33:20 +00:00
|
|
|
emit fish_cancel
|
2016-04-14 02:46:18 +00:00
|
|
|
end
|
2019-12-04 20:10:22 +00:00
|
|
|
# Repaint even if we haven't cancelled anything,
|
|
|
|
# so the prompt refreshes and the terminal scrolls to it.
|
|
|
|
commandline -f repaint
|
2016-04-14 02:46:18 +00:00
|
|
|
end
|