nix/shell: add starship prompt
This commit is contained in:
parent
d64a2d9709
commit
e4e21a3346
6 changed files with 72 additions and 6 deletions
|
@ -23,7 +23,6 @@ in
|
|||
home.packages = with pkgs; [
|
||||
# TODO: move packages to separate modules
|
||||
|
||||
any-nix-shell # fish and zsh support fo nix-shell
|
||||
asciinema # record the terminal
|
||||
neofetch # command-line system information
|
||||
|
||||
|
@ -46,7 +45,11 @@ in
|
|||
wm.xmonad.enable = true;
|
||||
|
||||
# shell
|
||||
shell.zsh.enable = true;
|
||||
shell = {
|
||||
zsh.enable = true;
|
||||
|
||||
prompt.starship.enable = true;
|
||||
};
|
||||
|
||||
# programs
|
||||
progs = {
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
[
|
||||
./zsh.nix
|
||||
]
|
||||
[ ./zsh.nix ] ++ (import ./prompt)
|
||||
|
|
1
nix/shell/prompt/default.nix
Normal file
1
nix/shell/prompt/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
[ ./starship ]
|
31
nix/shell/prompt/starship/config.nix
Normal file
31
nix/shell/prompt/starship/config.nix
Normal 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;
|
||||
};
|
||||
}
|
28
nix/shell/prompt/starship/default.nix
Normal file
28
nix/shell/prompt/starship/default.nix
Normal 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;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -15,6 +15,9 @@ in
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
# fish and zsh support fo nix-shell
|
||||
home.packages = with pkgs; [ any-nix-shell ];
|
||||
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
enableAutosuggestions = true;
|
||||
|
@ -32,7 +35,7 @@ in
|
|||
};
|
||||
|
||||
oh-my-zsh = {
|
||||
enable = true;
|
||||
enable = !config.shell.prompt.starship.enable;
|
||||
theme = "robbyrussell";
|
||||
};
|
||||
|
||||
|
@ -53,6 +56,8 @@ in
|
|||
'';
|
||||
|
||||
initExtra = ''
|
||||
any-nix-shell zsh --info-right | source /dev/stdin
|
||||
|
||||
eval "$(cat $HOME/repos/tas/shell/zsh)"
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue