Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elvish support #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions bin/any-nix-shell
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,44 @@ EOF
done
}

function init_elvish() {
output+=$(cat <<EOF
# If you see this output, you probably forgot to 'eval' it:
# eval (any-nix-shell $@ | slurp)

# Overwrite the nix-shell command
edit:add-var nix-shell~ [@_args]{
$(which .any-nix-shell-wrapper) elvish \$@_args
}

# Overwrite the nix command
edit:add-var nix~ [cmd @_args]{
if (==s \$cmd shell) {
$(which .any-nix-wrapper) elvish \$@_args
} else {
command nix \$cmd \$@_args
}
}
EOF
)
for arg in "$@"; do
case "$arg" in
--info-right)
output+=$(cat <<EOF


# Print additional information inside a nix-shell environment
edit:rprompt = {
print ($(which nix-shell-info) | slurp)" "
}

EOF
);;
*) error;;
esac
done
}

function error () {
echo "echo ERROR: wrong usage"
echo "bash -c \"\$(exit 1)\""
Expand All @@ -93,6 +131,7 @@ output=
case "$1" in
fish) init_fish "${@:2}";;
zsh) init_zsh "${@:2}";;
elvish) init_elvish "${@:2}";;
*) error;;
esac

Expand Down