nix-configs/modules/home-manager/cli/cli.nix

71 lines
1.6 KiB
Nix
Raw Normal View History

2025-07-06 21:49:22 +01:00
{
config,
lib,
pkgs,
...
}:
let
cfg = config.feature.cli;
in
{
options.feature.cli = {
enable = lib.mkEnableOption "Set up the CLI";
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
starship
tree
];
programs.fish = {
enable = true;
functions.fish_greeting = "";
shellInitLast = lib.mkIf (lib.strings.hasSuffix "darwin" pkgs.system) ''
eval $(/opt/homebrew/bin/brew shellenv)
'';
};
programs.fzf = {
enable = true;
enableFishIntegration = true;
};
programs.zsh = lib.mkIf (lib.strings.hasSuffix "darwin" pkgs.system) {
enable = true;
# zsh is a POSIX compliant shell and a safe default, but if it's an interactive
# shell and fish is not in the parent processes (i.e. I'm not deliberately starting
# zsh to use interactively from fish) then just launch fish.
initContent = ''
[[ $- == *i* ]] || return
is_parent_fish() {
local ppid=$$
while [[ $ppid -ne 1 ]]; do
local ppname=$(ps -p $ppid -o comm=)
if [[ "$ppname" == *fish* ]]; then
return 1
fi
ppid=$(ps -o ppid= -p $ppid)
done
return 0
}
if is_parent_fish
then
exec fish -l
fi
'';
};
programs.starship = {
enable = true;
enableFishIntegration = true;
enableInteractive = true;
enableTransience = true;
settings = builtins.fromTOML (builtins.readFile ./starship.toml);
};
};
}