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

26
flake.lock generated
View File

@@ -125,11 +125,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"lastModified": 1732030699, "lastModified": 1732109232,
"narHash": "sha256-SBosboLvLqDv+7mNgRTIYDQbHE61rDDkXTJWiRX3PPo=", "narHash": "sha256-iYh6h8yueU8IyOfNclbiBG2+fBFcjjUfXm90ZBzk0c0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "disko", "repo": "disko",
"rev": "da52cf40206d7d1a419d07640eb47b2fb9ac2c21", "rev": "a0c384e0a3b8bcaed30a6bcf3783f8a7c8b35be4",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -490,11 +490,11 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1731978971, "lastModified": 1732100541,
"narHash": "sha256-P9DXCxDvjFt4aMc2x67hvSpNvSqX18X840w6cEVZXoo=", "narHash": "sha256-vFeNbKUstvSZbe9TD4bDYozZd+A/bKD+fxCye+p/Mp8=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "67cee430061626ccd73dc6d30eed9db289053608", "rev": "940f7aa990dbc99815bab8d355999d8277534b17",
"revCount": 5480, "revCount": 5484,
"submodules": true, "submodules": true,
"type": "git", "type": "git",
"url": "https://github.com/hyprwm/Hyprland" "url": "https://github.com/hyprwm/Hyprland"
@@ -886,11 +886,11 @@
}, },
"nur": { "nur": {
"locked": { "locked": {
"lastModified": 1732045661, "lastModified": 1732117323,
"narHash": "sha256-SJW1HVIbav/8NlEFMqfiqrhaKcpbMqMFCTZ0cOikXgA=", "narHash": "sha256-QtvUTcCAfocg18O2V4VcnKn42tRooSuVC2S4s1rD8ek=",
"owner": "nix-community", "owner": "nix-community",
"repo": "NUR", "repo": "NUR",
"rev": "8ee137273e4a24ac661b43a195848beac5b3bd04", "rev": "aa6fc91ec7d36fbd6c44f63e16cfbc89a993a3b8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -969,11 +969,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1731989835, "lastModified": 1732076204,
"narHash": "sha256-Y1S+x2jWLQB9hn4aG04/213ZlTp+30itKe9KcSsrFgw=", "narHash": "sha256-FnPuD4CnVos1vlHcLceBvv4hHkv2zHive7OzC4xy6ys=",
"owner": "gerg-l", "owner": "gerg-l",
"repo": "spicetify-nix", "repo": "spicetify-nix",
"rev": "aac6c81489f61034916efa4ed62840dc1d72c413", "rev": "62ac6a2953a8bdfe7a0f7451f8a76ca1d73a6c9f",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

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

View File

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

View File

@@ -20,6 +20,11 @@ in
export RESULT export RESULT
echo "\$RESULT = $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() { nvim() {
${shellsound} ${sndpath}/nvim.wav ${shellsound} ${sndpath}/nvim.wav
command nvim "$@" command nvim "$@"
@@ -29,9 +34,11 @@ in
command ssh "$@" command ssh "$@"
kitty_ssh_theme kitty_ssh_theme
} }
kitty_ssh_theme() { kitty_theme() {
if [ -n "$SSH_CONNECTION" ]; then if [ -n "$SSH_CONNECTION" ]; then
kitty @ set-colors -a ~/.config/kitty/ssh-theme.conf 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 else
kitty @ set-colors -a ~/.config/kitty/default-theme.conf kitty @ set-colors -a ~/.config/kitty/default-theme.conf
fi fi
@@ -154,7 +161,7 @@ in
autoload -U down-line-or-beginning-search; zle -N down-line-or-beginning-search autoload -U down-line-or-beginning-search; zle -N down-line-or-beginning-search
bindkey -v bindkey -v
kitty_ssh_theme kitty_theme
type starship_zle-keymap-select >/dev/null || \ type starship_zle-keymap-select >/dev/null || \
{ {
eval "$(starship init zsh)" eval "$(starship init zsh)"

View File

@@ -3,28 +3,34 @@
# This folder is for programs that do not have existing configuration modules in NixOS. # 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. # Basically a to-do list for stuff I need to write my own modules for.
let let
# Custom theme that activates in ssh # Extract color scheme from base_16 yaml file
ssh_base16 = "atelier-cave"; 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; def_scheme = config.lib.stylix.colors;
scheme_path = "${pkgs.base16-schemes}/share/themes/${ssh_base16}.yaml";
scheme_string = builtins.readFile scheme_path; # Custom theme for nix-shell
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;
in { in {
options = { options = {
movOpts.homeFiles.enable = movOpts.homeFiles.enable =
@@ -210,6 +216,41 @@ in {
color14 #${ssh_scheme.base0F} color14 #${ssh_scheme.base0F}
color15 #${ssh_scheme.base07} 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 ./barbar.nix
./cmp.nix ./cmp.nix
./lsp.nix ./lsp.nix
./rustaceanvim.nix
./fidget.nix ./fidget.nix
./lualine.nix ./lualine.nix
./nvim-lightbulb.nix ./nvim-lightbulb.nix

View File

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

View File

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

View File

@@ -2,8 +2,7 @@
pkgs.writeShellApplication { pkgs.writeShellApplication {
name = "nsp"; name = "nsp";
text = '' text = ''
#!/run/current-system/sw/bin/bash trap 'NIX_SHELL=false kitty_theme' exit
NIX_SHELL=true command nix-shell -p "$@" --run zsh
nix-shell -p "$@" --run zsh
''; '';
} }