From abdba0a223441238ef15be85beaa90d76f923501 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 9 May 2021 21:13:24 +0200 Subject: [PATCH] home: pager: fix colorized man pages Turns out that sessionVariables are not being set at the proper time for use with `tput`. This commit also cleans up a bit how the config was being set. --- home/pager.nix | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/home/pager.nix b/home/pager.nix index 74a4c3b..9f0dc5e 100644 --- a/home/pager.nix +++ b/home/pager.nix @@ -7,27 +7,32 @@ in enable = mkDisableOption "pager configuration"; }; - config.programs.lesspipe.enable = cfg.enable; - config.home.sessionVariables = lib.mkIf cfg.enable { - # My default pager - PAGER = "less"; - # Clear the screen on start and exit - LESS = "-R -+X -c"; + config = lib.mkIf cfg.enable { + programs.lesspipe.enable = true; - # Colored man pages - LESS_TERMCAP_mb = "$(tput bold; tput setaf 2)"; - LESS_TERMCAP_md = "$(tput bold; tput setaf 6)"; - LESS_TERMCAP_me = "$(tput sgr0)"; - LESS_TERMCAP_so = "$(tput bold; tput setaf 3; tput setab 4)"; - LESS_TERMCAP_se = "$(tput rmso; tput sgr0)"; - LESS_TERMCAP_us = "$(tput bold; tput setaf 2)"; - LESS_TERMCAP_ue = "$(tput rmul; tput sgr0)"; - LESS_TERMCAP_mr = "$(tput rev)"; - LESS_TERMCAP_mh = "$(tput dim)"; - LESS_TERMCAP_ZN = "$(tput ssubm)"; - LESS_TERMCAP_ZV = "$(tput rsubm)"; - LESS_TERMCAP_ZO = "$(tput ssupm)"; - LESS_TERMCAP_ZW = "$(tput rsupm)"; + home.sessionVariables = { + # My default pager + PAGER = "less"; + # Clear the screen on start and exit + LESS = "-R -+X -c"; + }; + + programs.zsh.localVariables = { + # Colored man pages + LESS_TERMCAP_mb = "$(tput bold; tput setaf 2)"; + LESS_TERMCAP_md = "$(tput bold; tput setaf 6)"; + LESS_TERMCAP_me = "$(tput sgr0)"; + LESS_TERMCAP_so = "$(tput bold; tput setaf 3; tput setab 4)"; + LESS_TERMCAP_se = "$(tput rmso; tput sgr0)"; + LESS_TERMCAP_us = "$(tput bold; tput setaf 2)"; + LESS_TERMCAP_ue = "$(tput rmul; tput sgr0)"; + LESS_TERMCAP_mr = "$(tput rev)"; + LESS_TERMCAP_mh = "$(tput dim)"; + LESS_TERMCAP_ZN = "$(tput ssubm)"; + LESS_TERMCAP_ZV = "$(tput rsubm)"; + LESS_TERMCAP_ZO = "$(tput ssupm)"; + LESS_TERMCAP_ZW = "$(tput rsupm)"; + }; }; }