Command Shell: Difference between revisions
Adds section on using different shell in nix development environments Tags: Mobile edit Mobile web edit Advanced mobile edit |
m →Aliases: fix indentation |
||
| (4 intermediate revisions by 4 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 [https://en.wikipedia.org/wiki/Unix_shell 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, e.g. | {{note|[[Zsh]] is used here as an example. You can use other shells, e.g. [[Fish]] or [[Nushell]].}} | ||
== Enable == | == Enable == | ||
| Line 39: | Line 39: | ||
users.users.myuser.useDefaultShell = true; | users.users.myuser.useDefaultShell = true; | ||
</nowiki>}} | </nowiki>}} | ||
== Aliases == | |||
You can set aliases for all shells via: | |||
{{File|3=environment.shellAliases = { | |||
rebuild = "sudo nixos-rebuild switch --flake /etc/nixos/#nixos"; | |||
};|name=/etc/nixos/configuration.nix|lang=nix}} | |||
== Using a different shell in nix-shell and nix develop == | == Using a different shell in nix-shell and nix develop == | ||
| Line 75: | Line 81: | ||
* Nested shells will require you to type <code>exit</code> twice, once to leave the inner shell and once to exit the Nix shell environment itself. | * Nested shells will require you to type <code>exit</code> twice, once to leave the inner shell and once to exit the Nix shell environment itself. | ||
* Potential for alias conflicts as overriding commands can introduce unintended side effects in scripts or other tooling that expects the standard behavior. | * Potential for alias conflicts as overriding commands can introduce unintended side effects in scripts or other tooling that expects the standard behavior. | ||
== Using Flakes == | |||
If you are using [[Flakes]] with fish, the 'command-not-found' error message will not work correctly, but can be fixed by disabling the builtin Nix <code>command-not-found</code> program:<ref>https://github.com/NixOS/nixpkgs/issues/425613#issuecomment-3076081921</ref> | |||
{{File|3=programs.command-not-found.enable = false;|name=/etc/nixos/configuration.nix|lang=nix}} | |||
== See also == | == See also == | ||
| Line 80: | Line 90: | ||
* [[Nushell]] | * [[Nushell]] | ||
* [[Zsh]] | * [[Zsh]] | ||
* [[Flakes]] | |||
== References == | |||
[[Category:Configuration]] | [[Category:Configuration]] | ||
[[Category:Software]] | [[Category:Software]] | ||
[[Category:Shell]] | [[Category:Shell]] | ||