Command Shell: Difference between revisions
imported>Artturin add enable |
imported>Flexagoon No edit summary |
||
Line 19: | Line 19: | ||
users.users.yourname.shell = pkgs.zsh; | users.users.yourname.shell = pkgs.zsh; | ||
</nowiki>}} | </nowiki>}} | ||
== Changing /bin/sh == | |||
{{Warning|Please note that NixOS assumes all over the place that shell to be Bash, so override the default setting only if you know exactly what you're doing.}} | |||
{{ic|/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 what shell the user is using. /bin/sh doesn't have to be the same as your interactive shell (e.g. the one you use in your terminal). In fact, a lot of 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 | |||
<syntaxhighlight lang="nix"> | |||
# Dash is just an example, you can use whatever you want | |||
environment.binsh = "${pkgs.dash}/bin/dash"; | |||
</syntaxhighlight> | |||
== See also == | == See also == | ||
* [[Zsh]] | * [[Zsh]] |
Revision as of 05:55, 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.
Enable
Always enable the shell, otherwise it wont source the necessary files.
/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:
/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
/etc/nixos/configuration.nix
users.users.yourname.shell = pkgs.zsh;
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 what shell the user is using. /bin/sh doesn't have to be the same as your interactive shell (e.g. the one you use in your terminal). In fact, a lot of 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";