Terminal Search in WebShell

Terminal Search in WebShell

8月 21, 2023 · 1 分钟阅读时长 · 71 字 · -阅读 -评论

install

npm i xterm-addon-search

const searchAddon = new SearchAddon();

term.loadAddon(searchAddon);

Notes

On the alternate screen (e.g., within vi), search results may be inaccurate, since the content loaded by vi isn’t necessarily the full file. For commands like cat, terminal-level search works fine. On the alternate screen, prefer the editor’s built-in search.

Determine whether the terminal is in normal or alternate screen with:

term.buffer.active.type === 'normal'

To listen for changes, use term.onBufferChange.

Alan H
Authors
开发者,数码产品爱好者,喜欢折腾,喜欢分享,喜欢开源