Advertisement
thioshp

BatMan

Apr 11th, 2020
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.73 KB | None | 0 0
  1. #!/data/data/com.termux/files/usr/bin/bash
  2.  
  3. ####
  4. # Author:   Paul Thiong'o <thioshp@outlook.com>
  5. # Created on:   Tue, 15 Oct 2019 2047
  6. # Machine used: Termux on iTel
  7. # Purpose:  Prettify the display of a man page by piping to `col` then to the `bat` pager.
  8. #
  9. ####
  10.  
  11. # Variables
  12.  
  13. pname=`basename "$0"`
  14. usage="$pname is used to prettify a manual page using bat.\n"
  15. syntax="$pname <COMMAND>\n"
  16. errormsg="ERROR: $pname will exit because you didn't give a command whose man page you wish to view.\n"
  17.  
  18. # Exit on less than 1 args
  19. if [ $# -lt 1 ];
  20. then
  21.     echo -e "$errormsg";
  22.     echo -e "$usage";
  23.     echo -e "$syntax";
  24.     shift;
  25. else
  26.     # Pipe man's output thru `col` then pipe to `bat` pager
  27.     man "$1" | col -bx | bat --language man
  28.  
  29.  
  30. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement