bash下如何使用bind[En]
You can determine the character sequence emitted by a key by pressing Ctrl-v at the command line, then pressing the key you're interested in. On my system for F12, I get ^[[24~
.
The ^[
represents Esc.
Different types of terminals or terminal emulators can emit different codes for the same key.
At a Bash prompt you can enter a command like this to enable the key macro so you can try it out.
bind '"\e[24~":"foobar"'
Now, when you press F12, you'll get "foobar" on the command line ready for further editing. If you wanted a keystroke to enter a command immediately, you can add a newline:
bind '"\e[24~":"pwd\n"'
Now when you press F12, you'll get the current directory displayed without having to press Enter. What if you've already typed something on the line and you use this which automatically executes? It could get messy. However,
you could clear the line as part of your macro:
bind '"\e[24~":"\C-k \C-upwd\n"'
The space makes sure that the Ctrl-u has something to delete to keep the bell from ringing.
Once you've gotten the macro working the way you want, you can make it persistent by adding it to your ~/inputrc
file.
There's no need for the bind
command
or the outer set of single quotes:
"\e[24~":"\C-k \C-upwd\n"
Edit:
You can also create a key binding that will execute something without disturbing the current command line.
bind -x '"\eW":"who"'
Then while you're typing a command that requires a username, for example, and you need to know the names of user who are logged in, you can press Alt-Shift-W and the output of who
will
be displayed and the prompt will be re-issued with your partial command intact and the cursor in the same position in the line.
Unfortunately, this doesn't work properly for keys such as F12 which output more than two characters. In some cases this can be worked around.
The command (who
in
this case) could be any executable - a program, script or function.
bash下如何使用bind[En]的更多相关文章
- Git bash下中文乱码问题
Git bash下中文乱码--解决方案 解决办法1: 在git bash下,右键 出现下图,选择options: 选择"Text" 将Character set设置为 UTF-8 ...
- bash下几个替换运算符的区分
bash下几个替换运算符的区分 2012-03-21 22:20:54 分类: Python/Ruby 一直对四个替换运算符比较的迷惑,分布太清楚,记下来避免再次遗忘: ${name:-word} ...
- bash下. : () {} [] [[]] (())的解释 (非原创,侵删)
Copy from http://blog.chinaunix.net/uid-20380484-id-1692999.html bash下有很多像{}.[]等一些符号命令,下面是我对一些常用的符号命 ...
- bash下输入命令的几个常用快捷键
------------------------------------------ 先区分下vi里的命令 快速在行里移动光标 b 是往前部一个单词一个单词的移动 e 是往后部一个单词一个单词的移 ...
- bash下. : () {} [] [[]] (())的解释
bash下有很多像{}.[]等一些符号命令,下面是我对一些常用的符号命令的学习笔记,若有错误或纰漏望各位兄弟指正. 一..(source).(点)与source命令一样,从文件中读取并执行命令,无论该 ...
- ES6下的Function.bind方法
在JavaScript的使用中,this的指向问题始终是一个难点.不同的调用方式,会使this指向不同的对象.而使用call,apply,bind等方式,可改变this的指向,完成一些令人惊叹的黑魔法 ...
- Git Bash下实现复制粘贴等快速编辑功能
在windows下使用Git Bash会经常用到选中.复制.粘贴等功能,但是一般用的方法会很复杂,笔者经过查阅一些资料,特整理一些常见编辑功能的实现方法. (1)默认方法: 单击左上角的logo ic ...
- Git 使用问题 - win7 git bash下git pull失败
win7 旗舰版,从github上pull代码时,git bash命令出现错误 Administrator@rust-PC /g/rust_proj/cardslib (master) $ git - ...
- git bash 下操作文件及文件夹命令
1, cd : change directory的简写,改变目录的意思,就是切换到哪个目录下, 如 cd e:\fff 切换 E 盘下面的fff 目录. 当我们用cd 进入文件夹时,我们可以使用 通 ...
随机推荐
- Web Service进阶(三)HTTP-GET, HTTP-POST and SOAP的比较
XML Web Service支持三种协议来与用户交流数据.这三种协议分别是: 1.SOAP:Simple Object Access Protocol 2.HTTP-GET 3.HTTP-POST ...
- 自定义控件辅助神器ViewDragHelper
ViewDragHelper作为官方推出的手势滑动辅助工具,极大的简化了我们对手势滑动的处理逻辑,v4包中的SlidingPaneLayout和DrawerLayout内部都有ViewDragHelp ...
- Android简易实战教程--第六话《开发一键锁屏应用2·完成》
转载请注明出处:http://blog.csdn.net/qq_32059827/article/details/51885687点击打开链接 上一篇,初步开发了这个应用,功能都有了(见http:// ...
- TortoiseSVN文件夹图标不显示
伴随着十二月的脚步,小编带领的市委组织部项目有条不紊的进行着,在最近的项目中遇到一个问题TortoiseSVN文件夹的图标不显示,为什么小编已经安装好TortoiseSVN了,发现文件夹的图标还是系统 ...
- Dynamics CRM 注册插件dll到GAC
以server2012为例,搜索cmd,打开红框中的命令框,gacutil.exe -i "dll路径" 通过该命令把需要用到dll注册进gac(这里包括你的插件dll和你插件中引 ...
- oracle对大对象类型操作:blob,clob,nclob
1.基本介绍 Oracle和plsql都支持lob(large object) 类型,用来存储大数量数据,如图像文件,声音文件等.Oracle 9i realse2支持存储最大为4g的数据,or ...
- MVPHelper更新日志 --- 新增常规分包模式
MVPHelper是一款可以自动生成MVP接口以及实现类的android studio插件,彻底解放双手! MVPHelper更新版本啦. 由于之前只支持contract模式,不是很符合大众口味 所以 ...
- MO_GLOBAL - EBS R12 中 Multi Org 设计的深入研究(1)
在改EBS的BUG过程中,会在网上查找很多资料,这次是碰到一个多组织(Multi Org)的问题,发现Anil Passi写的几篇文章不错,慢慢的会陆续翻译过来,这次翻译的是http://getapp ...
- 【Android 应用开发】 自定义 圆形进度条 组件
转载著名出处 : http://blog.csdn.net/shulianghan/article/details/40351487 代码下载 : -- CSDN 下载地址 : http://down ...
- Guava 教程1-使用 Google Collections,Guava,static imports 编写漂亮代码
原文出处: oschina (API:http://ifeve.com/category/framework/guava-2/ JAR DOC Source 链接:http://pan.baidu.c ...