zsh: Automatically set color scheme at init

upower
Simon Bruder 2021-07-25 08:58:57 +02:00
parent aef0baf527
commit a67ec1b22f
Signed by: simon
GPG Key ID: 8D3C82F9F309F8EC
1 changed files with 14 additions and 1 deletions

View File

@ -1,4 +1,4 @@
{ lib, pkgs, ... }:
{ lib, nixosConfig, pkgs, ... }:
let
dircolors-solarized = pkgs.fetchFromGitHub {
owner = "seebi";
@ -8,6 +8,14 @@ let
meta.license = lib.licenses.mit;
};
# automatically set color scheme based on sun with dynamic-colors
dcauto =
let
latitude = (toString nixosConfig.location.latitude) + (if nixosConfig.location.latitude > 0 then "N" else "S");
longitude = (toString nixosConfig.location.longitude) + (if nixosConfig.location.longitude > 0 then "E" else "W");
in
"${pkgs.sunwait}/bin/sunwait poll civil ${latitude} ${longitude} | grep -qE '^DAY$' && dynamic-colors switch solarized-light || dynamic-colors switch solarized-dark";
in
{
programs = {
@ -53,6 +61,7 @@ in
];
shellAliases = {
cp = "cp --reflink=auto"; # TODO: remove with coreutils > 8.32
dcauto = dcauto;
dcsd = "dynamic-colors switch solarized-dark";
dcsl = "dynamic-colors switch solarized-light";
exa = "exa --git --binary";
@ -66,6 +75,10 @@ in
vim = "nvim";
vimdiff = "nvim -d";
};
initExtraFirst = ''
# automatic color scheme
${dcauto}
'';
initExtra = lib.mkMerge [
(lib.mkBefore ''
prompt off # collides with starship