在 bash 中按 alt + numeric 你会得到 (arg [numeric]) 那是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/562115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 20:41:55  来源:igfitidea点击:

Press alt + numeric in bash and you get (arg [numeric]) what is that?

bashshellkeyboard-shortcutsreadline

提问by dreftymac

Press alt + numeric in bash and you get (arg [numeric]) what is that?

在 bash 中按 alt + numeric 你会得到 (arg [numeric]) 那是什么?

(This type of question is better suited for asking a human, instead of trying to "guess" for the correct terminology to search on the documentation via internet).

(这种类型的问题更适合询问人类,而不是试图“猜测”正确的术语以通过互联网搜索文档)。

采纳答案by dreftymac

The term you want to google for is:

你想用谷歌搜索的术语是:

"readline arguments"

This will lead to, for example, this chapter from the bash reference manual:

例如,这将导致bash 参考手册中的本章

You can pass numeric arguments to Readline commands. Sometimes the argument acts as a repeat count, other times it is the sign of the argument that is significant. If you pass a negative argument to a command which normally acts in a forward direction, that command will act in a backward direction. For example, to kill text back to the start of the line, you might type 'M-- C-k'.

The general way to pass numeric arguments to a command is to type meta digits before the command. If the first 'digit' typed is a minus sign ('-'), then the sign of the argument will be negative. Once you have typed one meta digit to get the argument started, you can type the remainder of the digits, and then the command. For example, to give the C-d command an argument of 10, you could type 'M-1 0 C-d', which will delete the next ten characters on the input line.

您可以将数字参数传递给 Readline 命令。有时参数充当重复计数,有时它是重要参数的符号。如果您将否定参数传递给通常以正向作用的命令,则该命令将向后作用。例如,要将文本删除回行首,您可以键入“M-- C-k”。

将数字参数传递给命令的一般方法是在命令前键入元数字。如果键入的第一个“数字”是减号 (“-”),则参数的符号将为负。一旦您输入了一个元数字来启动参数,您就可以输入剩余的数字,然后输入命令。例如,要给 Cd 命令一个参数 10,您可以键入“M-1 0 C-d”,这将删除输入行中接下来的十个字符。

For that to work, you have to know where the Meta key is mapped: sometimes it's Alt, sometimes it's Esc, cool computers have a dedicated Meta key ;)

为此,您必须知道 Meta 键的映射位置:有时是Alt,有时是Esc,很酷的计算机有一个专用的 Meta 键 ;)

For those not familiar with the syntax, 'M-- C-k' is the equivalent of Meta_key+-Ctrl+k. "M" is shorthand for the Meta key, which, as noted, varies by system, "C" is shorthand for the Ctrl key. The "-" after a character (like "M-") is not something you type, it's a way of indicating simultaneous key presses.

对于那些不熟悉语法的人,'M-- Ck' 相当于Meta_key+ -Ctrl+ k。“M”是 Meta 键的简写,如前所述,它因系统而异,“C”是 Ctrl 键的简写。字符后的“-”(如“M-”)不是您键入的内容,它是表示同时按下按键的一种方式。

回答by guv'

In order to repeat numeric characters - e.g. 128 zeroes, hit the following:

为了重复数字字符 - 例如 128 个零,点击以下内容:

Meta-key + 128Ctrl + v0

Meta-key + 128Ctrl + v0

回答by Sean Bright

Try this. Type Alt4, then type T, then hit Enter.

尝试这个。键入Alt4,然后键入T,然后点击Enter

Edited to use the snazzier HTML.

编辑以使用更时髦的 HTML。

回答by Nietzche-jou

It repeats the next command given that many times, same as in Emacs. E.g. M-1-0 C-pmoves back 10 history items. M-4 C-hbackspaces four characters, M-3 M-tmoves the previous word forward three times, and so on. Here I use M-meaning "meta" for the Alt key, as is the custom in Bash.

它会多次重复下一个命令,就像在 Emacs 中一样。例如,M-1-0 C-p向后移动 10 个历史项目。M-4 C-h退格四个字符,M-3 M-t将前一个单词向前移动 3 次,依此类推。在这里,我使用M-Alt 键的意思是“元”,就像 Bash 中的自定义一样。

回答by stsquad

I know this has already an accepted answer however I did find some useful examplesthat also demonstrate additional uses aside from simple repeating of characters. The digit arguments can apply to all sorts of things. For example the sequence "Alt+3, Escape, Backspace" will delete backwards 3 words.

我知道这已经是一个公认的答案,但是我确实找到了一些有用的示例这些示例还演示了除了简单重复字符之外的其他用途。数字参数可以应用于各种事物。例如序列“Alt+3, Escape, Backspace”将向后删除 3 个单词。

回答by Giancarlo

I don't know but when you do alt + numeric and then you press a character, you'll get num caracters: (arg: 123) + a -> 123 times "a"

我不知道,但是当你执行 alt + numeric 然后你按下一个字符时,你会得到 num 个字符:(arg: 123) + a -> 123 次 "a"

回答by Douglas Leeder

bash manual section- basically a way of repeating readline commands, or reversing them.

bash 手册部分- 基本上是一种重复 readline 命令或反转它们的方法。