[Nix-dev] Defining system-wide shell aliases
Rickard Nilsson
rickard.nilsson at telia.com
Tue Jul 24 21:09:19 CEST 2012
On Tue, 24 Jul 2012 17:06:53 +0200, Florian Friesdorf
<flo at chaoflow.net> wrote:
> On Tue, 24 Jul 2012 17:00:29 +0200, "Rickard Nilsson"
> <rickard.nilsson at telia.com> wrote:
>> Hi,
>>
>> I want to define system-wide shell aliases. environment.shellInit
>> doesn't
>> help me, since it is only run for login shells, and aliases are not
>> inherited between processes. Essentially, I would like a way to put
>> stuff
>> into /etc/bashrc. Is it wise adding an option to NixOS for doing
>> this
>> (environment.shellSource or something)? Or can it be solved in some
>> other
>> way?
>
> Aliases work across different shells, what about:
>
> /etc/aliasrc
> environment.aliasrc
>
> And then adapt the generated config for zsh and bash to include that.
That sounds like a good approach.
Does anyone have any preference for syntax? Some suggestions:
environment.shellAliases = ''
alias ll='ls -lh'
alias year='date +%Y'
'';
or
environment.shellAliases = {
ll = "ls -lh";
year = "date +%Y";
};
or
environment.shellAliases = [
{ alias = "ll"; command = "ls -lh" }
{ alias = "year"; command = "date +%Y" }
];
I prefer the second example, but it might be a bit abusive on the
attribute set. We don't have tuples in Nix?
/ Rickard
More information about the nix-dev
mailing list