showgitmessage 399 B

12345678910111213141516171819
  1. #!/bin/sh
  2. # show preliminary git message in .git/message
  3. error_exit() {
  4. echo "Fatal: not a git repository (or any of the parent directories): .git"
  5. exit 1
  6. }
  7. cd_to_dotgit_dir() {
  8. while [ ! -d '.git' ]; do
  9. [ "$PWD" = "/" ] && error_exit
  10. cd ..
  11. done
  12. cd ".git" || error_exit
  13. }
  14. cd_to_dotgit_dir
  15. [ -f "message" ] && bat --style plain --theme "base16" -H 1 "message"