TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

If you use vi-mode under bash, and you miss ESC-dot, Ctrl-a, Ctrl-e, etc

1 点作者 ttsiodras大约 13 年前
I recently found out about vi-mode under bash:<p><pre><code> set -o vi </code></pre> I love it - but there's a problem: over the years I've formed "muscle memory" for the default bash (actually, readline) shortcuts:<p><pre><code> "ESC-." will reproduce my last line's last argument "Ctrl-a" will take me to the line's beginning "Ctrl-e" will take me to the line's end "Ctrl-w" deletes the word before the cursor "Ctrl-l" clears the screen </code></pre> These obviously don't work in vi-mode - "ESC-." for example switches to VI command mode (because of ESC) and then "." repeats the last inserted word.<p>After a bit of research, I found a way to have my cake and eat it too - this is what you need in your .bashrc:<p><pre><code> set -o vi bind -m vi-command ".":insert-last-argument bind -m vi-insert "\C-l.":clear-screen bind -m vi-insert "\C-a.":beginning-of-line bind -m vi-insert "\C-e.":end-of-line bind -m vi-insert "\C-w.":backward-kill-word </code></pre> This way, the shortcuts I've been using for decades still work - and I can still switch to vi command mode (with ESC) and enjoy the immense powers of vi.<p>Granted, I am losing a bit of functionality (e.g. the repeating of a series of commands with a single '.') ; but if you are like me, you'll prefer this tradeoff.<p>P.S. If you need further commands to replicate, just look them up in "man bash" (search for "Readline Command Names").

暂无评论

暂无评论