在 bash 中,如何清除当前输入? [英] In bash, how does one clear the current input?

查看:35
本文介绍了在 bash 中,如何清除当前输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您在 bash 中开始编写如下命令:

Suppose in bash you start writing a command like:

$ rm -rf /foo/bar/really/long/path/here

然后意识到您根本不想执行此操作.有没有办法通过一两次按键清除输入?

and then realize you don't want to execute this after all. Is there a way to clear the input with one or two keystrokes?

我最近一直在做的是在 echo 之前加上引号并将输入括起来 (Ctrl+A, echo ", Ctrl+E, ") 然后按回车键.有没有更快的方法?

What I have been doing lately is prepending echo and enclosing the input in quotes (Ctrl+A, echo ", Ctrl+E, ") then hitting enter. Is there a faster way?

推荐答案

  1. Ctrl-U 删除光标前的所有内容.删除的命令将存储到缓冲区中.按 Ctrl-Y 粘贴删除的命令.

  1. Press Ctrl-U to delete everything before the cursor. The deleted command will be stored into a buffer. Press Ctrl-Y to paste the deleted command.

(可选:按 EndCtrl-E 先跳到输入的结尾.)

(Optional: Press End or Ctrl-E to jump to the end of the input first.)

或者,按 Ctrl-C 中止您正在输入的内容.

Alternatively, press Ctrl-C to abort what you're typing.

这篇关于在 bash 中,如何清除当前输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆