Last active
May 22, 2022 09:08
-
-
Save twlz0ne/6b7175a2fe85e692ec3e64bb7dcb245b to your computer and use it in GitHub Desktop.
Emacs as Pager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# Emacs as pager | |
# | |
# Author: gongqijian@gmail.com | |
# Created: 2021-06-06 16.08.51 | |
# Version: 0.1 | |
# | |
# Installation: | |
# | |
# ┌──── | |
# │ cp ./emacs-pager /usr/local/bin/emacs-pager | |
# │ echo 'export PAGER="MAN_PAGE=1 emacs-pager"' >> ~/.bashrc | |
# │ echo 'export GIT_PAGER="emacs-pager"' >> ~/.bashrc | |
# └──── | |
emacs -Q -nw --eval "\ | |
(progn | |
(setq inhibit-startup-screen t) | |
(add-hook 'emacs-startup-hook | |
(lambda () | |
(if (string= \"${MAN_PAGE}\" \"\") | |
(progn | |
(require 'ansi-color) | |
(ansi-color-apply-on-region (point-min) (point-max)) | |
(fundamental-mode)) | |
(require 'woman) | |
(save-excursion | |
(if (re-search-forward \"^[.']\" 1000 t) | |
(woman-decode-buffer) | |
(woman-man-buffer))) | |
(woman-mode)) | |
(read-only-mode 1))))" --insert <(cat) </dev/tty | |
# emacs-pager ends here |
Author
twlz0ne
commented
Jun 6, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment