Configure less to show colors by default

To see more informations, see: https://superuser.com/a/337640/881905
This commit is contained in:
2022-11-14 01:36:56 +01:00
parent d836fff263
commit 2f44b15ff9
2 changed files with 25 additions and 0 deletions

View File

@@ -71,6 +71,9 @@ alias markdown_pdf="docker run --rm -v \$PWD:/opt/docs auchida/markdown-pdf mark
alias vimwiki='vim -c VimwikiIndex -c "cd %:p:h" -c "silent Git pull"'
alias wiki='vim -c VimwikiIndex -c "cd %:p:h" -c "silent Git pull"'
export LESS='-R'
export LESSOPEN='|~/.local/bin/lessfilter %s'
# Enable autocompletion for "config" to manage dotfiles
__git_complete config __git_main

22
.local/bin/lessfilter Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
case "$1" in
*.awk|*.groff|*.java|*.js|*.m4|*.php|*.pl|*.pm|*.pod|*.sh|\
*.ad[asb]|*.asm|*.inc|*.[ch]|*.[ch]pp|*.[ch]xx|*.cc|*.hh|\
*.lsp|*.l|*.pas|*.p|*.xml|*.xps|*.xsl|*.axp|*.ppd|*.pov|\
*.diff|*.patch|*.py|*.rb|*.sql|*.ebuild|*.eclass|*.vim|\
.vimrc|*.yaml|*.yml|*.json|*.properties|*.html|*.scss|\
*.css|*.ts)
pygmentize -f 256 "$1";;
.bashrc|.bash_aliases|.bash_environment|.profile)
pygmentize -f 256 -l sh "$1";;
*)
if grep -q "#\!/bin/bash" "$1" 2> /dev/null; then
pygmentize -f 256 -l sh "$1"
else
exit 1
fi
esac
exit 0