Added nix-shell plugin to oh-my-zsh

This commit is contained in:
KoenDR06 2024-07-21 20:45:22 +02:00
parent 70e0c63886
commit 7712beeeb4
5 changed files with 249 additions and 0 deletions

View file

@ -0,0 +1,26 @@
#! /usr/bin/env sh
if [ "$1" = "--rcfile" ]; then
# This means the shell should stay open after executing. So we remove the last line which contains 'exit'
shift
tmp="$(cat $1)"
echo ${tmp%exit} > $1
cat >> $1 <<EOF
SHELL=$NIX_EXECUTING_SHELL
unset NIX_BUILD_SHELL
FPATH=\$(echo 'echo \$FPATH' | $NIX_EXECUTING_SHELL --stdin)
for path in \${PATH//:/ }; do
if [[ \$path = /nix/store/* ]]; then
path=\${path/%bin/share\/zsh\/site-functions}
if [ -d "\$path" ]; then
FPATH="\$path:\$FPATH"
fi
fi
done
FPATH=\$FPATH $NIX_EXECUTING_SHELL
EOF
/usr/bin/env bash $1
else
/usr/bin/env bash "$@"
fi