Difference between revisions of "Command Shell"
From NixOS Wiki
m (add software and configuration categories) |
m (rollback unauthorized mass edits) Tag: Rollback |
||
(13 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
A shell is a program that translates text commands (like {{ic|ls}}, {{ic|vim}}, {{ic|reboot}} etc) into instructions for your computer. The default shell on NixOS is [[bash]], but it can be easily changed. | A shell is a program that translates text commands (like {{ic|ls}}, {{ic|vim}}, {{ic|reboot}} etc) into instructions for your computer. The default shell on NixOS is [[bash]], but it can be easily changed. | ||
− | {{note|[[Zsh]] is used here as an example. You can use other shells, | + | {{note|[[Zsh]] is used here as an example. You can use other shells, e.g. {{ic|fish}} or {{ic|nushell}}.}} |
== Enable == | == Enable == | ||
− | + | When adding a new shell, always enable the shell system-wide, even if it's already enabled in your [[Home Manager]] configuration, otherwise it won't source the necessary files. | |
+ | |||
+ | For example, for [[Zsh]]: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
programs.zsh.enable = true; | programs.zsh.enable = true; | ||
</nowiki>}} | </nowiki>}} | ||
− | == Changing default shell == | + | == Changing the default shell == |
− | + | ||
+ | === For all users === | ||
+ | |||
+ | To set a command shell as the default for all users, use the [https://search.nixos.org/options?query=defaultUserShell <code>defaultUserShell</code>] option. | ||
+ | |||
+ | For example, to set Zsh as the default user shell for all users: | ||
+ | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
users.defaultUserShell = pkgs.zsh; | users.defaultUserShell = pkgs.zsh; | ||
</nowiki>}} | </nowiki>}} | ||
− | |||
− | To | + | === For a specific user === |
+ | |||
+ | To set a command shell as the default for a particular user, use the [https://search.nixos.org/options?query=%3Cname%3E.shell <code><nowiki><name></nowiki>.shell</code>] option. | ||
+ | |||
+ | For example, to set user "myuser"'s shell to [[fish]]: | ||
+ | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
− | users.users. | + | users.users.myuser.shell = pkgs.fish; |
− | </nowiki>}} | + | </nowiki>}} |
− | + | You can also choose whether or not a user should use the default shell: | |
− | |||
− | |||
− | + | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | |
− | < | + | users.users.myuser.useDefaultShell = true; |
− | + | </nowiki>}} | |
− | |||
− | </ | ||
== See also == | == See also == | ||
+ | * [[Fish]] | ||
+ | * [[Nushell]] | ||
* [[Zsh]] | * [[Zsh]] | ||
− | |||
[[Category:Configuration]] | [[Category:Configuration]] | ||
[[Category:Software]] | [[Category:Software]] |
Latest revision as of 11:03, 6 April 2024
A shell is a program that translates text commands (like ls
, vim
, reboot
etc) into instructions for your computer. The default shell on NixOS is bash, but it can be easily changed.
Enable
When adding a new shell, always enable the shell system-wide, even if it's already enabled in your Home Manager configuration, otherwise it won't source the necessary files.
For example, for Zsh:
/etc/nixos/configuration.nix
programs.zsh.enable = true;
Changing the default shell
For all users
To set a command shell as the default for all users, use the defaultUserShell
option.
For example, to set Zsh as the default user shell for all users:
/etc/nixos/configuration.nix
users.defaultUserShell = pkgs.zsh;
For a specific user
To set a command shell as the default for a particular user, use the <name>.shell
option.
For example, to set user "myuser"'s shell to fish:
/etc/nixos/configuration.nix
users.users.myuser.shell = pkgs.fish;
You can also choose whether or not a user should use the default shell:
/etc/nixos/configuration.nix
users.users.myuser.useDefaultShell = true;