Command Shell: Difference between revisions
imported>Skylark m Minor copyedit throughout |
imported>Liassica →Enable: Changed vague "home.nix" wording |
||
Line 3: | Line 3: | ||
{{note|[[Zsh]] is used here as an example. You can use other shells, e.g. {{ic|fish}} or {{ic|nushell}}.}} | {{note|[[Zsh]] is used here as an example. You can use other shells, e.g. {{ic|fish}} or {{ic|nushell}}.}} | ||
== Enable == | == Enable == | ||
Always enable the shell system-wide, even if it's already enabled in your | 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. | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
programs.zsh.enable = true; | programs.zsh.enable = true; |
Revision as of 01:10, 11 November 2023
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
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.
/etc/nixos/configuration.nix
programs.zsh.enable = true;
Changing the default shell
defaultUserShell
in the options search
useDefaultShell
in the options search
To only change the default shell for one of the users, see
<name>.shell <name>.shell
in the options search
Changing /bin/sh
/bin/sh
is a symlink to your default POSIX-compliant shell. It's used when writing shell scripts, so that the script works on all machines independently of which shell the user is using. /bin/sh doesn't have to be the same as your interactive shell (i.e. the one you use in your terminal). For example, some people set their interactive shells to zsh/fish but set /bin/sh to dash, because it's fast and scripts don't need any of those fancy zsh/fish features.
To change your default POSIX shell on NixOS, use
# Dash is just an example, you can use whatever you want
environment.binsh = "${pkgs.dash}/bin/dash";