From fa5fd321252c2ca20bab97297fd3615f195786fa Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Tue, 12 Oct 2021 13:07:33 -0400 Subject: [PATCH] spruce up powerline formatting and theme --- modules/cli/bold.patch | 13 +++++++++++++ modules/cli/powerline.nix | 25 ++++++++++++++++++++----- 2 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 modules/cli/bold.patch diff --git a/modules/cli/bold.patch b/modules/cli/bold.patch new file mode 100644 index 0000000..fffde24 --- /dev/null +++ b/modules/cli/bold.patch @@ -0,0 +1,13 @@ +diff --git a/powerline.go b/powerline.go +index 0b640ac..7778ebf 100644 +--- a/powerline.go ++++ b/powerline.go +@@ -177,7 +177,7 @@ func (p *powerline) color(prefix string, code uint8) string { + } + + func (p *powerline) fgColor(code uint8) string { +- return p.color("38", code) ++ return p.color("1;38", code) + } + + func (p *powerline) bgColor(code uint8) string { diff --git a/modules/cli/powerline.nix b/modules/cli/powerline.nix index 49465f6..c79c173 100644 --- a/modules/cli/powerline.nix +++ b/modules/cli/powerline.nix @@ -1,6 +1,16 @@ { config, pkgs, lib, ... }: let + cfg = config.sconfig.powerline; + + theme = pkgs.writeText "powerline.json" (builtins.toJSON + { + CwdFg = 15; + PathFg = 15; + PathBg = 24; + SeparatorFg = 16; + }); + in { options.sconfig.powerline = @@ -12,10 +22,10 @@ in args = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ - "-colorize-hostname" - "-cwd-mode=plain" - "-modules=user,host,cwd,nix-shell,git,jobs" + "-modules=\${remote:+'user,host,'}nix-shell,git,jobs,cwd" "-git-assume-unchanged-size 0" + "-theme ${theme}" + "-path-aliases '~/git=~/git'" "-jobs $(jobs -p | wc -l)" ]; }; @@ -23,11 +33,16 @@ in config = lib.mkIf cfg.enable { - environment.systemPackages = [ pkgs.powerline-go ]; + environment.systemPackages = [ + (pkgs.powerline-go.overrideAttrs (old: { patches = [ ./bold.patch ]; })) + ]; programs.bash.interactiveShellInit = '' function _update_ps1() { - PS1="\n$(powerline-go ${lib.concatStringsSep " " cfg.args})$ " + local remote=y + [ "$XDG_SESSION_TYPE" = "x11" ] && unset remote + [ "$XDG_SESSION_TYPE" = "wayland" ] && unset remote + PS1="\n$(powerline-go ${lib.concatStringsSep " " cfg.args})" } [ "$TERM" = "linux" ] || PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND" '';