Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply iceberg color scheme on Linux console to avoid unreadable ANSI Blue #665

Merged
merged 9 commits into from
Jul 11, 2024
Merged
4 changes: 4 additions & 0 deletions home-manager/bash.nix
Original file line number Diff line number Diff line change
@@ -127,6 +127,10 @@
${lib.getBin pkgs.coreutils}/bin/stty stop undef

source "${config.xdg.configHome}/posix_shells/shared_functions.sh"

if [ 'linux' = "$TERM" ]; then
apply_iceberg
fi
''
+ builtins.readFile ./initExtra.bash;

32 changes: 32 additions & 0 deletions home-manager/common.nix
Original file line number Diff line number Diff line change
@@ -152,6 +152,38 @@
gch() {
fc -nrl 1 | ${lib.getExe homemade-pkgs.fzf-bind-posix-shell-history-to-git-commit-message}
}

# See the reason in GH-660
# Original scheme: https://gist.github.com/cocopon/1d481941907d12db7a0df2f8806cfd41
apply_iceberg() {
# Blue. Mandatory to be changed from ANSI
echo -en "\e]P484a0c6"
echo -en "\e]PC91acd1"

# Black
echo -en "\e]P01e2132"
echo -en "\e]P86b7089"

# Red
echo -en "\e]P1e27878"
echo -en "\e]P9e98989"

# Green
echo -en "\e]P2b4be82"
echo -en "\e]PAc0ca8e"

# Yellow
echo -en "\e]P3e2a478"
echo -en "\e]PBe9b189"

# Magenta
echo -en "\e]P5a093c7"
echo -en "\e]PDada0d3"

# White
echo -en "\e]P7c6c8d1"
echo -en "\e]PFd2d4de"
}
'';

xdg.configFile."wezterm" = {
4 changes: 4 additions & 0 deletions home-manager/zsh.nix
Original file line number Diff line number Diff line change
@@ -205,6 +205,10 @@

source_sh "${config.xdg.configHome}/posix_shells/shared_functions.sh"

if [ 'linux' = "$TERM" ]; then
apply_iceberg
fi

# https://superuser.com/a/902508/120469
# https://github.com/zsh-users/zsh-autosuggestions/issues/259
zshaddhistory() { whence ''${''${(z)1}[1]} >| /dev/null || return 1 }
36 changes: 36 additions & 0 deletions nixos/configuration.nix
Original file line number Diff line number Diff line change
@@ -368,6 +368,42 @@ in
};
};

# Apply better fonts for non X consoles
# https://github.com/NixOS/nixpkgs/issues/219239
boot.initrd.kernelModules = [ "amdgpu" ];
# https://wiki.archlinux.org/title/Linux_console
console = {
earlySetup = true;
# The font should have PSF formats. Do not specify TTF and OTF
# You can list current glyphs with `showconsolefont`
font = "ter-u24n";

packages = with pkgs; [
# https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/data/fonts/terminus-font/default.nix#L41-L43
terminus_font
];
keyMap = "us";
};

# Better console appearance even if no X, but do not use for now with the unstable behaviors
# https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/ttys/kmscon.nix
services.kmscon = {
enable = false;
hwRender = false;
fonts = with pkgs; [
{
name = "IBM Plex Mono";
package = ibm-plex;
}
{
name = "Noto Color Emoji";
package = noto-fonts-color-emoji;
}
];
extraConfig = "font-size=24";
extraOptions = "--term xterm-256color";
};

# https://nixos.wiki/wiki/Podman
virtualisation = {
containers.enable = true;