powerline-go: add zsh integration

wip/yesman
Martin Toman 4 years ago committed by Robert Helgesson
parent cde1d33e61
commit b04aa56503
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
  1. 35
      modules/programs/powerline-go.nix
  2. 0
      tests/modules/programs/powerline-go/bash.nix
  3. 5
      tests/modules/programs/powerline-go/default.nix
  4. 31
      tests/modules/programs/powerline-go/zsh.nix

@ -106,17 +106,38 @@ in {
};
};
config = mkIf (cfg.enable && config.programs.bash.enable) {
programs.bash.initExtra = ''
function _update_ps1() {
local old_exit_status=$?
PS1="$(${pkgs.powerline-go}/bin/powerline-go -error $old_exit_status ${commandLineArguments})"
config = {
programs.bash.initExtra =
mkIf (cfg.enable && config.programs.bash.enable) ''
function _update_ps1() {
local old_exit_status=$?
PS1="$(${pkgs.powerline-go}/bin/powerline-go -error $old_exit_status ${commandLineArguments})"
${cfg.extraUpdatePS1}
return $old_exit_status
}
if [ "$TERM" != "linux" ]; then
PROMPT_COMMAND="_update_ps1;$PROMPT_COMMAND"
fi
'';
programs.zsh.initExtra = mkIf (cfg.enable && config.programs.zsh.enable) ''
function powerline_precmd() {
PS1="$(${pkgs.powerline-go}/bin/powerline-go -error $? -shell zsh ${commandLineArguments})"
${cfg.extraUpdatePS1}
return $old_exit_status
}
function install_powerline_precmd() {
for s in "$\{precmd_functions[@]}"; do
if [ "$s" = "powerline_precmd" ]; then
return
fi
done
precmd_functions+=(powerline_precmd)
}
if [ "$TERM" != "linux" ]; then
PROMPT_COMMAND="_update_ps1;$PROMPT_COMMAND"
install_powerline_precmd
fi
'';
};

@ -1 +1,4 @@
{ powerline-go-standard = ./standard.nix; }
{
powerline-go-bash = ./bash.nix;
powerline-go-zsh = ./zsh.nix;
}

@ -0,0 +1,31 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs = {
zsh.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" ];
};
};
};
nixpkgs.overlays =
[ (self: super: { zsh = pkgs.writeScriptBin "dummy-zsh" ""; }) ];
nmt.script = ''
assertFileExists home-files/.zshrc
assertFileContains \
home-files/.zshrc \
'/bin/powerline-go -error $? -shell zsh -modules nix-shell -newline -path-aliases \~/project/foo=prj-foo -ignore-repos /home/me/project1,/home/me/project2'
'';
};
}
Loading…
Cancel
Save