[20231109]bash shell快捷键alt+number的问题.txt

–//前一阵子,我想实现12行合并1行的输出,理论讲要使用paste命令加入12个- .输入命令时候要数输入了多少-.我知道bash shell有一
–//个快捷键alt+number可以产生连续输入某个字符,但是我一直不知道如何关掉这个功能.有时候误触发这个功能,有一些版本每次输入1
–//个字符相当于输入多个,我不知道如何关闭,出现这样情况我基本选择关闭会话,重新登陆.

–//比如输入:
$ seq 12 | paste – – – –

–//可以这样操作,输入:
seq 12 | paste –
–//然后移动回去加入空格.
–//有一些版本存在bug,比如你再使用方向键向左移动,相当于移动向左移动4个字符.使用完成后必须关闭它.
–//打入一个字符会出现4个相同字符的情况.
–//我测试一下,发现使用可以关闭,好像这个问题存在于早期bash shell版本中。

# man bash
Numeric Arguments
digit-argument (M-0, M-1, …, M–)
Add this digit to the argument already accumulating, or start a new argument. M– starts a negative argument.

–//怎么还能输入负数,不理解,负数实际上反向操作。
111 222 333 –//假设光标在最后,删除3个词。
111 222 333 –//假设光标在1的位置,也能实现相同效果。

universal-argument
This is another way to specify an argument. If this command is followed by one or more digits, optionally with a
leading minus sign, those digits define the argument. If the command is followed by digits, executing
universal-argument again ends the numeric argument, but is otherwise ignored. As a special case, if this command
is immediately followed by a character that is neither a digit nor minus sign, the argument count for the next
command is multiplied by four. The argument count is initially one, so executing this function the first time makes
the argument count four, a second time makes the argument count sixteen, and so on.

通用参数

这是指定参数的另一种方法。如果此命令后面跟着一个或多个数字,或者带有前导负号,则这些数字将定义该参数。如果命令后面跟着数
字,则执行通用参数再次结束数字参数,否则将忽略。作为一种特殊情况,如果这个命令紧接着是一个既不是数字也不是负号的字符,下
一个命令的参数计数乘以4。参数计数最初是1,所以第一次执行这个函数使参数数4,第二次使参数数16,以此类推。
–//不理解?怎么意思。

–//如果你需要输出12 个1,如何操作呢?要输入ctrl+v.
–//, 1 .

–//另外我还看了一些blog,发现一个技巧就是利用它输入前面输入的参数.
–//假设先执行如下命令:
$ echo 1 2 3
1 2 3

$ echo 4 5 6
4 5 6

$ echo 7 8 9
7 8 9

–//要实现echo 1 5 9,可以这样操作.
–//显示echo,输入空格
–//显示1,输入空格
–//显示5,输入空格
–//显示9,回车执行.
–//最后一步可以使用显示最后一个参数.我个人很少使用这个功能,我喜欢在inputrc定义键抽取最后1个参数。
“\e[2~”: yank-last-arg # insert

–//有一些功能类似vim.比如
$ echo 0123456
–//想删除123456 6个字符,可以这样输入:

6
6
–//负数表示反向操作的意思。

–//链接上有一些介绍:
https://qastack.cn/programming/562115/press-alt-numeric-in-bash-and-you-get-arg-numeric-what-is-that

–//我前面的测试产生12个-.如果要实现输入12个-加空格,如何操作呢?
$ seq 24 | paste –

–// 先 ,删除”- “,记入缓存。
–// 然后,抽取缓存12次。
–// 我的测试无效!!不知道那位有什么好方法.