Difference between revisions of "Command Shell"

From NixOS Wiki
Jump to: navigation, search
(add enable)
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, eg {{ic|fish}}.}}
 +
== Enable ==
 +
Always enable the shell, otherwise it wont source the necessary files.
 +
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 +
programs.zsh.enable = true;
 +
</nowiki>}}
  
 
== Changing default shell ==
 
== Changing default shell ==
 
Shells can be changed system-wide and per-user. To change the shell system-wide, add the following line to your config:
 
Shells can be changed system-wide and per-user. To change the shell system-wide, add the following line to your config:
{{note|[[Zsh]] is used here as an example. You can use other shells, eg {{ic|pkgs.fish}}.}}
 
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
users.defaultUserShell = pkgs.zsh;
 
users.defaultUserShell = pkgs.zsh;
Line 11: Line 17:
 
To only change the default shell for one of the users, add
 
To only change the default shell for one of the users, add
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
shell = pkgs.zsh;
+
users.users.yourname.shell = pkgs.zsh;
</nowiki>}}
+
</nowiki>}}  
to your user's section like so:
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
 
users.users.yourname = {}
 
  ... # Your user configuration
 
  shell = pkgs.zsh;
 
};
 
</nowiki>}}
 
  
 
== See also ==
 
== See also ==
 
* [[Zsh]]
 
* [[Zsh]]

Revision as of 05:47, 12 June 2021

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.

Note: Zsh is used here as an example. You can use other shells, eg fish.

Enable

Always enable the shell, otherwise it wont source the necessary files.

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
programs.zsh.enable = true;


Changing default shell

Shells can be changed system-wide and per-user. To change the shell system-wide, add the following line to your config:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
users.defaultUserShell = pkgs.zsh;

then run nixos-rebuild switch and reboot your system.

To only change the default shell for one of the users, add

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
users.users.yourname.shell = pkgs.zsh;


See also