kitty now changes color scheme inside of nix-shell

This commit is contained in:
2024-11-24 14:25:17 -05:00
parent 836f24d416
commit ebe5b4d8df
9 changed files with 103 additions and 40 deletions

View File

@@ -12,7 +12,7 @@
right_format = "($custom)";
format = lib.concatStrings [
"($ssh_symbol)($username)($hostname)(bold white)($cmd_duration)($character)"
"($ssh_symbol)($username)($hostname)($nix_shell)(bold white)($cmd_duration)($character)"
"($git_branch)($git_status)($rust)($nix-shell)"
"($directory)"
"$line_break[ > ](bold #89b4fa)"
@@ -59,6 +59,11 @@
format = "[@](bold blue)[$hostname](bold red)";
};
nix_shell = {
format = " via [$symbol]($style)";
symbol = " ";
};
custom.shellver = {
command = "zsh --version";
when = ''test $SHELL = "/run/current-system/sw/bin/zsh"'';

View File

@@ -48,6 +48,7 @@ in {
gtrash
ripgrep
toilet
vkbasalt
] ++ scripts;
};
}

View File

@@ -20,6 +20,11 @@ in
export RESULT
echo "\$RESULT = $RESULT"
}
nix-shell() {
# set an environment variable to track if you're in a nix shell or not
trap 'NIX_SHELL=false kitty_theme' EXIT
NIX_SHELL=true command nix-shell "$@" --run zsh
}
nvim() {
${shellsound} ${sndpath}/nvim.wav
command nvim "$@"
@@ -29,9 +34,11 @@ in
command ssh "$@"
kitty_ssh_theme
}
kitty_ssh_theme() {
kitty_theme() {
if [ -n "$SSH_CONNECTION" ]; then
kitty @ set-colors -a ~/.config/kitty/ssh-theme.conf
elif [ "$name" = "nix-shell-env" ] || [ "$NIX_SHELL" = "true" ]; then
kitty @ set-colors -a ~/.config/kitty/nix-shell-theme.conf
else
kitty @ set-colors -a ~/.config/kitty/default-theme.conf
fi
@@ -154,7 +161,7 @@ in
autoload -U down-line-or-beginning-search; zle -N down-line-or-beginning-search
bindkey -v
kitty_ssh_theme
kitty_theme
type starship_zle-keymap-select >/dev/null || \
{
eval "$(starship init zsh)"

View File

@@ -3,28 +3,34 @@
# This folder is for programs that do not have existing configuration modules in NixOS.
# Basically a to-do list for stuff I need to write my own modules for.
let
# Custom theme that activates in ssh
ssh_base16 = "atelier-cave";
# Extract color scheme from base_16 yaml file
extractSchemeFromYaml = base16_scheme: let
scheme_path = "${pkgs.base16-schemes}/share/themes/${base16_scheme}.yaml";
scheme_string = builtins.readFile scheme_path;
scheme_list = lib.splitString "\n" scheme_string;
colors =
lib.filter (line: builtins.match "^ *base[0-9A-F]{2}: .*" line != null)
scheme_list;
parsed_scheme = lib.lists.foldl' (acc: line:
let
splitLine = lib.splitString ": " line;
key = builtins.elemAt splitLine 0;
value = builtins.elemAt splitLine 1;
trimmedKey = lib.trim key;
cleanValue_step1 = lib.splitString " " value;
cleanValue_step2 = builtins.elemAt cleanValue_step1 0;
cleanValue_final =
builtins.substring 1 (builtins.stringLength cleanValue_step2 - 2)
cleanValue_step2;
in acc // { "${trimmedKey}" = cleanValue_final; }) { } colors;
in parsed_scheme;
ssh_scheme = extractSchemeFromYaml "atelier-cave" ;
nix-shell_scheme = extractSchemeFromYaml "apathy";
def_scheme = config.lib.stylix.colors;
scheme_path = "${pkgs.base16-schemes}/share/themes/${ssh_base16}.yaml";
scheme_string = builtins.readFile scheme_path;
scheme_list = lib.splitString "\n" "${scheme_string}";
colors =
lib.filter (line: builtins.match "^ *base[0-9A-F]{2}: .*" line != null)
scheme_list;
ssh_scheme = lib.lists.foldl' (acc: line:
let
splitLine = lib.splitString ": " line;
key = builtins.elemAt splitLine 0;
value = builtins.elemAt splitLine 1;
trimmedKey = lib.trim key;
cleanValue_step1 = lib.splitString " " value;
cleanValue_step2 = builtins.elemAt cleanValue_step1 0;
cleanValue_final =
builtins.substring 1 (builtins.stringLength cleanValue_step2 - 2)
cleanValue_step2;
in acc // { "${trimmedKey}" = cleanValue_final; }) { } colors;
# Custom theme for nix-shell
in {
options = {
movOpts.homeFiles.enable =
@@ -210,6 +216,41 @@ in {
color14 #${ssh_scheme.base0F}
color15 #${ssh_scheme.base07}
'';
".config/kitty/nix-shell-theme.conf".text = ''
background #${nix-shell_scheme.base00}
foreground #${nix-shell_scheme.base05}
selection_background #${nix-shell_scheme.base05}
selection_foreground #${nix-shell_scheme.base00}
url_color #${nix-shell_scheme.base04}
cursor #${nix-shell_scheme.base05}
active_border_color #${nix-shell_scheme.base03}
inactive_border_color #${nix-shell_scheme.base01}
active_tab_background #${nix-shell_scheme.base00}
active_tab_foreground #${nix-shell_scheme.base05}
inactive_tab_background #${nix-shell_scheme.base01}
inactive_tab_foreground #${nix-shell_scheme.base04}
tab_bar_background #${nix-shell_scheme.base01}
# normal
color0 #${nix-shell_scheme.base01}
color1 #${nix-shell_scheme.base08}
color2 #${nix-shell_scheme.base0B}
color3 #${nix-shell_scheme.base0A}
color4 #${nix-shell_scheme.base0D}
color5 #${nix-shell_scheme.base0E}
color6 #${nix-shell_scheme.base0C}
color7 #${nix-shell_scheme.base05}
# bright
color8 #${nix-shell_scheme.base03}
color9 #${nix-shell_scheme.base09}
color10 #${nix-shell_scheme.base01}
color11 #${nix-shell_scheme.base02}
color12 #${nix-shell_scheme.base04}
color13 #${nix-shell_scheme.base06}
color14 #${nix-shell_scheme.base0F}
color15 #${nix-shell_scheme.base07}
'';
};
};
}

View File

@@ -9,6 +9,7 @@
./barbar.nix
./cmp.nix
./lsp.nix
./rustaceanvim.nix
./fidget.nix
./lualine.nix
./nvim-lightbulb.nix

View File

@@ -20,7 +20,6 @@
nvim-surround.enable = true;
rainbow-delimiters.enable = true;
render-markdown.enable = true;
rustaceanvim.enable = true;
treesitter.enable = true;
trim.enable = true;
trouble.enable = true;

View File

@@ -0,0 +1,10 @@
{ ... }:
{
programs.nixvim.plugins.rustaceanvim = {
enable = true;
settings = {
server.auto_attach = true;
};
};
}