From ab6517d34a6f73dee356b601f363d10d71a46656 Mon Sep 17 00:00:00 2001 From: Vanilla Date: Tue, 3 Aug 2021 11:16:00 +0800 Subject: [PATCH] powerline-go: add fish integration --- modules/programs/powerline-go.nix | 9 ++++ .../modules/programs/powerline-go/default.nix | 1 + tests/modules/programs/powerline-go/fish.nix | 41 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 tests/modules/programs/powerline-go/fish.nix diff --git a/modules/programs/powerline-go.nix b/modules/programs/powerline-go.nix index 8f5db8f26..af06dd9d1 100644 --- a/modules/programs/powerline-go.nix +++ b/modules/programs/powerline-go.nix @@ -140,5 +140,14 @@ in { install_powerline_precmd fi ''; + + # https://github.com/justjanne/powerline-go#fish + programs.fish.promptInit = + mkIf (cfg.enable && config.programs.fish.enable) '' + function fish_prompt + eval ${pkgs.powerline-go}/bin/powerline-go -error $status -jobs (count (jobs -p)) ${commandLineArguments} + ${cfg.extraUpdatePS1} + end + ''; }; } diff --git a/tests/modules/programs/powerline-go/default.nix b/tests/modules/programs/powerline-go/default.nix index e89d7c6cd..49ed71d26 100644 --- a/tests/modules/programs/powerline-go/default.nix +++ b/tests/modules/programs/powerline-go/default.nix @@ -1,4 +1,5 @@ { powerline-go-bash = ./bash.nix; powerline-go-zsh = ./zsh.nix; + powerline-go-fish = ./fish.nix; } diff --git a/tests/modules/programs/powerline-go/fish.nix b/tests/modules/programs/powerline-go/fish.nix new file mode 100644 index 000000000..7009c8c29 --- /dev/null +++ b/tests/modules/programs/powerline-go/fish.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +{ + config = { + programs = { + fish.enable = true; + + powerline-go = { + enable = true; + newline = true; + modules = [ "nix-shell" ]; + pathAliases = { "\\~/project/foo" = "prj-foo"; }; + settings = { + ignore-repos = [ "/home/me/project1" "/home/me/project2" ]; + }; + }; + }; + + # Needed to avoid error with dummy fish package. + xdg.dataFile."fish/home-manager_generated_completions".source = + mkForce (builtins.toFile "empty" ""); + + nixpkgs.overlays = [ + (self: super: + let dummy = pkgs.writeScriptBin "dummy" ""; + in { + powerline-go = dummy; + fish = dummy; + }) + ]; + + nmt.script = '' + assertFileExists home-files/.config/fish/config.fish + assertFileContains \ + home-files/.config/fish/config.fish \ + '/bin/powerline-go -error $status -jobs (count (jobs -p)) -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2' + ''; + }; +}