Skip to content

Commit

Permalink
Merge pull request #6 from nrdxp/fix-nix-run
Browse files Browse the repository at this point in the history
`nix run` is now `nix shell`
  • Loading branch information
haslersn authored Dec 29, 2020
2 parents 8c857d4 + b90891b commit e6b86e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# any-nix-shell
`fish` and `zsh` support for the `nix run` and `nix-shell` environments of the Nix package manager.
`fish` and `zsh` support for the `nix shell` and `nix-shell` environments of the Nix package manager.

Features:

* When entering a `nix run` or `nix-shell` environment, the shell stays the same.
* When entering a `nix shell` or `nix-shell` environment, 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 --command` or the like still execute inside `bash`, such that scripts don't break.
Expand Down Expand Up @@ -81,4 +81,4 @@ The `any-nix-shell` command (which is used for enabling the plugin in a specific

| Flag | Description |
| - | - |
| `--info-right` | While in a `nix run` or `nix-shell` environment, display information about the loaded packages at the right. |
| `--info-right` | While in a `nix shell` or `nix-shell` environment, display information about the loaded packages at the right. |
6 changes: 3 additions & 3 deletions bin/.any-nix-run-wrapper → bin/.any-nix-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fns () {
pos=$((pos-1))
elif [[ $arg == -* ]]; then
if [[ $arg == -c ]] || [[ $arg == --command ]]; then
command nix run "$@"
command nix shell "$@"
return
elif [[ $arg == --arg ]] || [[ $arg == --argstr ]]; then
pos=2
Expand All @@ -27,6 +27,6 @@ fns () {
if [[ -n $name ]] && [[ $name != shell ]]; then
pkgs+=" "$name
fi
env ANY_NIX_SHELL_PKGS="$pkgs" IN_NIX_RUN=1 nix run "$@" --command $which_shell
env ANY_NIX_SHELL_PKGS="$pkgs" IN_NIX_RUN=1 nix shell "$@" --command $which_shell
}
fns "$@"
fns "$@"
8 changes: 4 additions & 4 deletions bin/any-nix-shell
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ end
# Overwrite the nix command
function nix
if test \$argv[1] = run
if test \$argv[1] = shell
set argv[1] fish
$(which .any-nix-run-wrapper) \$argv
$(which .any-nix-wrapper) \$argv
else
command nix \$argv
end
Expand Down Expand Up @@ -51,9 +51,9 @@ function nix-shell () {
# Overwrite the nix command
function nix () {
if [[ \$1 == run ]]; then
if [[ \$1 == shell ]]; then
shift
$(which .any-nix-run-wrapper) zsh "\$@"
$(which .any-nix-wrapper) zsh "\$@"
else
command nix "\$@"
fi
Expand Down

0 comments on commit e6b86e6

Please sign in to comment.