nix/shell: add starship prompt

This commit is contained in:
Dmitriy Pleshevskiy 2022-08-24 14:02:45 +03:00
parent d64a2d9709
commit e4e21a3346
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
6 changed files with 72 additions and 6 deletions

View file

@ -23,7 +23,6 @@ in
home.packages = with pkgs; [ home.packages = with pkgs; [
# TODO: move packages to separate modules # TODO: move packages to separate modules
any-nix-shell # fish and zsh support fo nix-shell
asciinema # record the terminal asciinema # record the terminal
neofetch # command-line system information neofetch # command-line system information
@ -46,7 +45,11 @@ in
wm.xmonad.enable = true; wm.xmonad.enable = true;
# shell # shell
shell.zsh.enable = true; shell = {
zsh.enable = true;
prompt.starship.enable = true;
};
# programs # programs
progs = { progs = {

View file

@ -1,3 +1 @@
[ [ ./zsh.nix ] ++ (import ./prompt)
./zsh.nix
]

View file

@ -0,0 +1 @@
[ ./starship ]

View file

@ -0,0 +1,31 @@
{ concatStrings }:
{
add_newline = true;
format = concatStrings [
"$directory"
"$git_branch"
"$git_commit"
"$git_state"
"$git_metrics"
"$git_status"
"$nix_shell"
"$cmd_duration"
"$jobs"
"$line_break"
"$character"
];
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
git_commit.commit_hash_length = 6;
directory = {
truncate_to_repo = true;
truncation_length = 6;
};
}

View file

@ -0,0 +1,28 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.shell.prompt.starship;
starshipConfig = import ./config.nix {
inherit concatStrings;
};
in
{
options.shell.prompt.starship = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable starship cross-shell prompt";
};
};
config = mkIf cfg.enable {
programs.starship = {
enable = true;
enableZshIntegration = config.shell.zsh.enable;
settings = starshipConfig;
};
};
}

View file

@ -15,6 +15,9 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
# fish and zsh support fo nix-shell
home.packages = with pkgs; [ any-nix-shell ];
programs.zsh = { programs.zsh = {
enable = true; enable = true;
enableAutosuggestions = true; enableAutosuggestions = true;
@ -32,7 +35,7 @@ in
}; };
oh-my-zsh = { oh-my-zsh = {
enable = true; enable = !config.shell.prompt.starship.enable;
theme = "robbyrussell"; theme = "robbyrussell";
}; };
@ -53,6 +56,8 @@ in
''; '';
initExtra = '' initExtra = ''
any-nix-shell zsh --info-right | source /dev/stdin
eval "$(cat $HOME/repos/tas/shell/zsh)" eval "$(cat $HOME/repos/tas/shell/zsh)"
''; '';
}; };