如何在Linux下使用向上/向下键启用Android adb shell历史记录?

发布于 2024-10-08 09:51:37 字数 229 浏览 5 评论 0原文

我最近升级到了新的 Android SDK,我注意到一些非常非常麻烦的事情。看来无法再在 shell 中使用命令历史记录了。你注意到同样的情况了吗? Android shell 对我来说似乎很糟糕,但至少,在上一个 SDK 中,我有命令历史记录。现在,似乎按向上/向下箭头会导致在提示符上写入一些代码(例如 ^[[A、^[[B 等...)。我尝试阅读一些内容,但发现很少有人问这个问题的答案为零。知道为什么会发生这种情况以及如何解决这个问题吗?

I recently upgraded to the new Android SDK and I noticed something very very bothering. It seems it is no more possible to use the command history in the shell. Are you noticing the same? The Android shell seems horrible to me, but at least, in the last SDK, I had the command history. Now, it seems that pressing the up/down arrow, result in some codes written on the prompt (something like ^[[A, ^[[B etc...). I tried to read a little bit around but I found very few asking this a zero answers. Any idea why this happens and how to solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

森林散布 2024-10-15 09:51:37

您可以在 rlwrap 内运行 shell:

rlwrap adb shell

我更喜欢自己在 Emacs shell 缓冲区中运行它,如果你对 Emacs 不过敏的话我推荐这个。 Emacs 也非常适合运行 adb logcat:您可以获得可搜索的历史记录,并且消息会在出现时更新,并且您可以轻松地将有趣的图案放入颜色中(Mxhighlight-regexp 和朋友)。

You can run the shell inside rlwrap:

rlwrap adb shell

I prefer to run it in an Emacs shell buffer myself, I recommend this if you're not allergic to Emacs. Emacs is also nice for running adb logcat: you get a searchable history and the messages are updated as they come, and you can easily put interesting patterns in color (M-x highlight-regexp and friends).

云仙小弟 2024-10-15 09:51:37

如果您谈论的是真实设备(而不是模拟器),您应该尝试一些非官方固件,例如 Cyanogenmod - 它包括更好的二进制工具,例如功能更丰富的 shell、一套健全的常规 UNIX 工具、ssh 服务器等。

如果您谈论的是模拟器,您可以从固件中提取这些二进制文件并将其按原样推送到模拟器中(使用存储卡图像)。

If you're talking about real device (not emulator), you should try some non-official firmwares, such as Cyanogenmod - it includes much better binary tools, such as much more featureful shell, sane set of regular UNIX tools, ssh server, etc.

If you're talking about emulator, you can extract these binaries from firmwares and push it into emulator as is (using a memory card image).

蘑菇王子 2024-10-15 09:51:37

如果 Ctrl-p 仍然为您提供以前的历史记录条目,则箭头键可能由于某种原因变得未绑定。试试这个:

bind '"\e[A": previous-history'
bind '"\e[B": next-history'

如果这使得箭头键起作用,您可以通过将这两行添加到 /etc/inputrc~/.inputrc 来使其持久化:

"\e[A": previous-history
"\e[B": next-history

If Ctrl-p still gives you previous history entries, then it's possible that the arrow keys became unbound for some reason. Try this:

bind '"\e[A": previous-history'
bind '"\e[B": next-history'

If that makes the arrow keys work, you can make it persistent by adding these two lines to /etc/inputrc or ~/.inputrc:

"\e[A": previous-history
"\e[B": next-history
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文