简体   繁体   English

将powershell键盘绑定更新为像bash shell一样的emacs样式

[英]Update powershell keyboard bindings to be emacs style like bash shell

I'm fairly familiar with the default bash shell shortcuts (emacs style). 我对默认的bash shell快捷方式(emacs样式)非常熟悉。 For example, if I want to move my cursor forward by a word I would press Alt+F (same as you would in emacs). 例如,如果我想用一个单词向前移动光标,我会按Alt + F (与在emacs中相同)。 I can get to the previous command with Ctrl+P . 我可以使用Ctrl + P转到上一个命令。

Is it even possible in windows powershell to override these shortcuts? 甚至可以在Windows PowerShell中覆盖这些快捷方式吗? If so, does anyone know of a good way to map the default bash shell shortcut configurations to powershell (in a bash shell you can say set -o emacs , for example)? 如果是这样,有没有人知道将默认的bash shell快捷方式配置映射到powershell的好方法(例如在bash shell中你可以set -o emacs )?

If it helps, I don't really care about powershell per say, I care about posh-git shell. 如果它有帮助,我并不真的关心powershell每个说法,我关心posh-git shell。 However, git-shell inherits its properties from powershell from what I can tell. 但是,git-shell从powershell继承了它的属性。

You can do that with the PSReadLine module which ships with PowerShell 5.0 (Windows 10). 您可以使用PowerShell 5.0附带的PSReadLine模块(Windows 10)来实现。

Simply set the EditMode option to Emacs : 只需将EditMode选项设置为Emacs

Set-PSReadLineOption -EditMode Emacs

In addition to the default Windows mode, it also has a Vi mode. 除了默认的Windows模式,它还具有Vi模式。

The project README file mentions that neither are fully implemented so don't expect full feature parity, but I can confirm that it switches tab completion to bash-style and supports the Alt+F and Ctrl+P key bindings for moving forward and jumping to the previous command respectively 项目README文件提到既没有完全实现,所以不要期望完整的功能奇偶校验,但我可以确认它将标签完成切换为bash样式并支持Alt + FCtrl + P键绑定以前进和跳转到分别是上一个命令

(I'm not an experienced emacs user so I'm unable to tell whether this comes "close enough" to what you expect) (我不是一个经验丰富的emacs用户,所以我无法判断这是否与你期望的“足够接近”)

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

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