Skip to content

zsh plugin that lets you use zsh in nix-shell shell.

License

Notifications You must be signed in to change notification settings

esc-zsh/zsh-nix-shell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zsh in nix-shell

This oh-my-zsh plugin lets you use zsh as the default shell in a nix-shell environment. It's recommended to use this in conjunction with nix-zsh-completions.

Motivation

In theory all you need to do to use zsh in nix-shell is to set NIX_BUILD_SHELL to zsh. Unfortunatly nix assumes that the NIX_BUILD_SHELL is a bash variant and passes bash specific arguments to the shell. To fix this we need a shim that translates these arguments.

The information that nix-shell exposes to the environment is also pretty sparse. It would be nice to know what derivations are included in the current environment for example to display them in the shells prompt.

Installation

Oh-My-ZSH

git clone [email protected]:chisui/zsh-nix-shell.git $ZSH_CUSTOM/plugins/nix-shell

Then add nix-shell to the plugins list in ~/.zshrc.

Plain ZSH

Clone this repository and add the following to your ~/.zshrc.

source /path/to/zsh-nix-shell/nix-shell.plugin.zsh

Plugin managers

It should be possible to install this plugin through most zsh plugin managers. If the one of your choice is not supported feel free to open an issue or even better create a pull request.

Usage

Use nix-shell as you did before.

If you use the --run or --command argument to execute something inside the nix-shell and then return it will still be run using bash. In the case of --command the interactive shell will still be zsh.

--pure

If you use the --pure flag the resulting shell will be the default shell.

Environment info

If you are inside a nix-shell environment IN_NIX_SHELL will be set. The value will be impure or pure if you specified --pure.

The packages argument is passed through as NIX_SHELL_PACKAGES to the shell.

If this Variable is empty nix-shell was called for a specific nix expression which is stored in the name environment variable.

These variables can now be used inside a theme to customize the prompt. Take a look at this variant of the agnoster theme for an example of how this might look.

example prompt

example prompt for projects

Contributing

Please do. Pull requests welcome.

About

zsh plugin that lets you use zsh in nix-shell shell.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Shell 100.0%