26 lines
627 B
Bash
Executable file
26 lines
627 B
Bash
Executable file
#! /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
|
|
|