2020-04-24 23:36:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
prg = config.programs;
|
|
|
|
cfg = prg.thefuck;
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
bashAndZshInitScript = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
eval $(${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias})
|
|
|
|
'';
|
2022-04-27 09:35:20 +00:00
|
|
|
fishInitScript = ''
|
|
|
|
${pkgs.thefuck}/bin/thefuck --alias ${cfg.alias} | source
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
programs.thefuck = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption "thefuck, an app which corrects your previous console command";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
alias = mkOption {
|
|
|
|
default = "fuck";
|
|
|
|
type = types.str;
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
`thefuck` needs an alias to be configured.
|
|
|
|
The default value is `fuck`, but you can use anything else as well.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment.systemPackages = with pkgs; [ thefuck ];
|
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
programs.bash.interactiveShellInit = bashAndZshInitScript;
|
|
|
|
programs.zsh.interactiveShellInit = mkIf prg.zsh.enable bashAndZshInitScript;
|
|
|
|
programs.fish.interactiveShellInit = mkIf prg.fish.enable fishInitScript;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|