switch to elvish shell
This commit is contained in:
parent
c7e27e5594
commit
4434fa8922
5 changed files with 87 additions and 15 deletions
82
home-manager/modules/elvish.nix
Normal file
82
home-manager/modules/elvish.nix
Normal file
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.programs.elvish;
|
||||
in {
|
||||
options.programs.elvish = {
|
||||
enable = mkEnableOption "Elvish, a friendly interactive shell and an expressive programming";
|
||||
|
||||
defaultFromBash = mkOption {
|
||||
type = types.bool;
|
||||
default = cfg.enable;
|
||||
description = ''
|
||||
Launch automatically when an interactive Bash shell is started
|
||||
'';
|
||||
};
|
||||
|
||||
zoxide = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable zoxide smart directory switcher
|
||||
'';
|
||||
};
|
||||
|
||||
starship = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Use the starship prompt
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.elvish;
|
||||
defaultText = literalExpression "pkgs.elvish";
|
||||
description = ''
|
||||
The elvish package to install. May be used to change the version.
|
||||
'';
|
||||
};
|
||||
|
||||
initExtra = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
description = ''
|
||||
Elvish code called during interactive elvish shell
|
||||
initialisation.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [cfg.package];
|
||||
|
||||
# programs.man.generateCaches = mkDefault true;
|
||||
|
||||
xdg.configFile."elvish/rc.elv".text = cfg.initExtra;
|
||||
|
||||
programs.bash.enable = mkIf cfg.defaultFromBash true;
|
||||
programs.bash.initExtra = mkIf cfg.defaultFromBash "exec elvish";
|
||||
|
||||
programs.starship.enable = mkIf cfg.starship true;
|
||||
programs.zoxide.enable = mkIf cfg.zoxide true;
|
||||
|
||||
programs.starship.enableBashIntegration = mkIf cfg.defaultFromBash false;
|
||||
|
||||
programs.elvish.initExtra = mkMerge [
|
||||
(mkIf cfg.starship ''
|
||||
if (and (not-eq $E:TERM "dumb") (or (not (has-env "INSIDE_EMACS")) (eq $E:INSIDE_EMACS "vterm"))) {
|
||||
eval (${config.home.profileDirectory}/bin/starship init elvish)
|
||||
}
|
||||
'')
|
||||
(mkIf cfg.zoxide ''
|
||||
eval (${config.programs.zoxide.package}/bin/zoxide init elvish | slurp)
|
||||
'')
|
||||
];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue