bash: factor out colorized man into colorman script
This commit is contained in:
parent
0f8a8570eb
commit
4df02f2b0f
2 changed files with 43 additions and 24 deletions
|
@ -187,6 +187,9 @@ else
|
|||
alias lsc="/usr/bin/env CLICOLOR_FORCE=1 ls"
|
||||
fi
|
||||
|
||||
# Use my colorman wrapper if available.
|
||||
command -v colorman >/dev/null && alias man=colorman
|
||||
|
||||
alias ll="ls -l"
|
||||
alias lla="la -l"
|
||||
|
||||
|
@ -377,30 +380,6 @@ ltree() { tree -C "$@" | less -R; }
|
|||
# Combined mkdir and cd
|
||||
mkcd() { mkdir -p -- "$1" && cd -P -- "$1" || return; }
|
||||
|
||||
# Colorized `man`
|
||||
man() {
|
||||
local standout bold underline
|
||||
|
||||
if [ "$BACKGROUND" = "light" ]; then
|
||||
standout="$Base3$Cyan_BG"
|
||||
bold="$Blue"
|
||||
underline="$Base02$(tput smul)"
|
||||
else
|
||||
standout="$Base03$Cyan_BG"
|
||||
bold="$Yellow"
|
||||
underline="$Base3$(tput smul)"
|
||||
fi
|
||||
|
||||
LESS_TERMCAP_so="$standout" \
|
||||
LESS_TERMCAP_md="$bold" \
|
||||
LESS_TERMCAP_us="$underline" \
|
||||
LESS_TERMCAP_se="$Reset" \
|
||||
LESS_TERMCAP_me="$Reset" \
|
||||
LESS_TERMCAP_ue="$Reset" \
|
||||
GROFF_NO_SGR=1 \
|
||||
command man "$@"
|
||||
}
|
||||
|
||||
solarized() {
|
||||
local name rgb _bg n
|
||||
|
||||
|
|
40
roles/dotfiles/files/bin/colorman
Executable file
40
roles/dotfiles/files/bin/colorman
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
# Colorized man pages
|
||||
|
||||
Reset=$(tput sgr0)
|
||||
Base03=8
|
||||
Base02=0
|
||||
#Base01=10
|
||||
#Base00=11
|
||||
#Base0=12
|
||||
#Base1=14
|
||||
#Base2=7
|
||||
Base3=15
|
||||
#Red=1
|
||||
#Orange=9
|
||||
Yellow=3
|
||||
#Green=2
|
||||
Cyan=6
|
||||
Blue=4
|
||||
#Violet=13
|
||||
#Magenta=5
|
||||
|
||||
if [ "$BACKGROUND" = "light" ]; then
|
||||
standout=$( printf '%s\n' "setaf $Base3" "setab $Cyan" | tput -S)
|
||||
bold=$( printf '%s\n' "setaf $Blue" | tput -S)
|
||||
underline=$(printf '%s\n' "setaf $Base02" "smul" | tput -S)
|
||||
else
|
||||
standout=$( printf '%s\n' "setaf $Base03" "setab $Cyan" | tput -S)
|
||||
bold=$( printf '%s\n' "setaf $Yellow" | tput -S)
|
||||
underline=$(printf '%s\n' "setaf $Base3" "smul" | tput -S)
|
||||
fi
|
||||
|
||||
LESS_TERMCAP_so="$standout" \
|
||||
LESS_TERMCAP_md="$bold" \
|
||||
LESS_TERMCAP_us="$underline" \
|
||||
LESS_TERMCAP_se="$Reset" \
|
||||
LESS_TERMCAP_me="$Reset" \
|
||||
LESS_TERMCAP_ue="$Reset" \
|
||||
GROFF_NO_SGR=1 \
|
||||
man "$@"
|
||||
|
Loading…
Add table
Reference in a new issue