any-nix-shell
any-nix-shell copied to clipboard
fish and zsh support for the nix run and nix-shell environments of the Nix package manager
any-nix-shell
fish and zsh support for the nix run and nix-shell environments of the Nix package manager.
Features:
- When entering a
nix runornix-shellenvironment, the shell stays the same. - Inside those environments, your prompt prints the loaded packages to the right.
- Alternatively, print that information by executing:
nix-shell-info nix-shell --commandor the like still execute insidebash, such that scripts don't break.
Installation
any-nix-shell can currently be installed from the official nixos-unstable channel
(Link 1, Link 2).
If you don't know how to do that, you can alternatively execute
nix-env -i any-nix-shell -f https://github.com/NixOS/nixpkgs/archive/master.tar.gz
which installs any-nix-shell into your user environment.
Enabling
In the following we describe how to enable the any-nix-shell plugin
for your user.
This differs slightly between fish and zsh.
fish
Add the following to your ~/.config/fish/config.fish. Create it if it doesn't exist.
any-nix-shell fish --info-right | source
zsh
Add the following to your ~/.zshrc. Create it if it doesn't exist.
any-nix-shell zsh --info-right | source /dev/stdin
System-wide enabling on NixOS
Alternatively the any-nix-shell plugin can be enabled system-wide.
This enables it for every user.
To do so, add the following to your configuration (/etc/nixos/configuration.nix).
fish
programs.fish.enable = true;
programs.fish.promptInit = ''
any-nix-shell fish --info-right | source
'';
zsh
programs.zsh.enable = true;
programs.zsh.promptInit = ''
any-nix-shell zsh --info-right | source /dev/stdin
'';
zsh with home-manager
programs.zsh.enable = true;
programs.zsh.initExtra = ''
any-nix-shell zsh --info-right | source /dev/stdin
'';
Customization
The any-nix-shell command (which is used for enabling the plugin in a specific shell) optionally takes any of the following flags:
| Flag | Description |
|---|---|
--info-right |
While in a nix shell or nix-shell environment, display information about the loaded packages at the right. |