Terminal Search in WebShell

· 1 min read · 71 Words · -Views -Comments

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.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover