Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell agnostic aliases #2347

Merged
merged 1 commit into from Nov 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions modules/home-environment.nix
Expand Up @@ -227,6 +227,26 @@ in
'';
};

home.shellAliases = mkOption {
type = with types; attrsOf str;
default = { };
example = literalExample ''
{
g = "git";
"..." = "cd ../..";
}
'';
description = ''
An attribute set that maps aliases (the top level attribute names
in this option) to command strings or directly to build outputs.
</para><para>
This option should only be used to manage simple aliases that are
compatible across all shells. If you need to use a shell specific
feature then make sure to use a shell specific option, for example
<xref linkend="opt-programs.bash.shellAliases"/> for Bash.
'';
};

home.sessionVariables = mkOption {
default = {};
type = types.attrs;
Expand Down Expand Up @@ -466,6 +486,10 @@ in
&& config.submoduleSupport.externalPackageInstall
then "/etc/profiles/per-user/${cfg.username}"
else cfg.homeDirectory + "/.nix-profile";

programs.bash.shellAliases = cfg.shellAliases;
programs.zsh.shellAliases = cfg.shellAliases;
programs.fish.shellAliases = cfg.shellAliases;

home.sessionVariables =
let
Expand Down