简体   繁体   English

在 Ubuntu 终端中插入命令的键盘快捷键

[英]Keyboard Shortcut To Insert Command in Ubuntu Terminal

Does anyone know of a simple way to map a command to an unused keyboard shortcut so that when I press the shortcut when typing in the terminal it inserts the command?有谁知道将命令映射到未使用的键盘快捷键的简单方法,这样当我在终端中键入时按下快捷键时,它会插入命令? Specifically I'm looking to quickly execute the series of commands具体来说,我希望快速执行一系列命令

make; sudo make install; sudo ldconfig

It's not a long command, but I end up typing it about 100 times a day.这不是一个很长的命令,但我最终每天输入大约 100 次。 The ideal solution would work in any directory and would be automatically mapped on startup.理想的解决方案适用于任何目录,并在启动时自动映射。 OS is Ubuntu 12.10.操作系统是 Ubuntu 12.10。 Any suggestions?有什么建议?

Use a bash alias. 使用bash别名。

Put a line like this in your .bashrc, .bash_profile, or any file sourced in one of these. 在您的.bashrc,.bash_profile或其中任何一个源文件中放入这样的行。 I have a separate file for aliases called .bash_aliases. 我有一个单独的别名文件,称为.bash_aliases。

alias fullmake="make; sudo make install; sudo ldconfig"

Then you can just run fullmake in a shell. 然后,您可以在shell中运行fullmake。

Perhaps you may want to try https://github.com/dvorka/hstr which allows for "suggest box style" filtering of Bash history with (optional) metrics based ordering:也许您可能想尝试https://github.com/dvorka/hstr ,它允许使用基于(可选)指标的排序对 Bash 历史进行“建议框样式”过滤:

在此处输入图片说明

It can be easily bound to Ctrl-r and/or Ctrl-s - therefore you can insert to command prompt recently (and often) used commands quickly.它可以很容易地绑定到Ctrl-r和/或Ctrl-s - 因此您可以快速插入最近(和经常)使用的命令的命令提示符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM