Skip to content

Instantly share code, notes, and snippets.

@hym3242
Last active October 22, 2023 21:50
Show Gist options
  • Save hym3242/f5074431c39fd578a6805fd28b61e840 to your computer and use it in GitHub Desktop.
Save hym3242/f5074431c39fd578a6805fd28b61e840 to your computer and use it in GitHub Desktop.
Forcing the FreeBSD default man/less/top to use alternate screen.

Add this to your .profile/.bashrc etc:

altdo() { 
  echo -e '\e[?1049h'; "$@"; echo -e '\e[?1049l'; 
}

then run altdo man or altdo less, altdo top etc.

Explanation:

The escape sequences enable and disable the alternate screen before and after the command execution. If it is a non-interactive program you will see nothing, but can manually switch to alternate screen to see the output.

See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment