Skip to content

Instantly share code, notes, and snippets.

@twlz0ne
Last active May 22, 2022 09:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twlz0ne/6b7175a2fe85e692ec3e64bb7dcb245b to your computer and use it in GitHub Desktop.
Save twlz0ne/6b7175a2fe85e692ec3e64bb7dcb245b to your computer and use it in GitHub Desktop.
Emacs as Pager
#!/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
@twlz0ne
Copy link
Author

twlz0ne commented Jun 6, 2021

man git-log

Screenshot_2021-06-06_at_8 41 02_PM_emacs-as-pager-1

git log --oneline

Screenshot_2021-06-06_at_8 44 09_PM_emacs-as-pager-2

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