Skip to content
Open
Changes from 6 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
21 changes: 19 additions & 2 deletions bin/fresh
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,30 @@ fresh_after_build() {
}

_fresh_preamble() {

local no_path_export fresh_path user_shell="$(getent passwd $LOGNAME | cut -d: -f7)"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getent is not available on Mac OS X. Would it be possible to detect fish via the presence of an environment variable?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would using the $SHELL variable be more portable?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$SHELL should be fine.

if [[ $user_shell == *"fish"* ]]; then
no_path_export="set __FRESH_BIN_PATH__ (echo $FRESH_BIN_PATH | sed -e s@$HOME@\$HOME@)
if not contains \$__FRESH_BIN_PATH__ \$PATH
set -U fish_user_paths \$fish_user_paths \$__FRESH_BIN_PATH__
end
set -u __FRESH_BIN_PATH__
"
fresh_path="set -U FRESH_PATH=\"$FRESH_PATH\""
else
no_path_export="__FRESH_BIN_PATH__="${FRESH_BIN_PATH/#$HOME/\$HOME}"; [[ ! \$PATH =~ (^|:)\$__FRESH_BIN_PATH__(:|\$) ]] && export PATH=\"\$__FRESH_BIN_PATH__:\$PATH\"; unset __FRESH_BIN_PATH__"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be named path_export.

fresh_path="export FRESH_PATH=\"$FRESH_PATH\""
fi


if [ -z "${__FRESH_PREAMBLE_DONE__:-}" ]; then
if [ -z "${FRESH_NO_PATH_EXPORT:-}" ]; then
echo "__FRESH_BIN_PATH__="${FRESH_BIN_PATH/#$HOME/\$HOME}"; [[ ! \$PATH =~ (^|:)\$__FRESH_BIN_PATH__(:|\$) ]] && export PATH=\"\$__FRESH_BIN_PATH__:\$PATH\"; unset __FRESH_BIN_PATH__" >> "$FRESH_PATH/build.new/shell.sh"
echo "$no_path_export" >> "$FRESH_PATH/build.new/shell.sh"
fi
echo "export FRESH_PATH=\"$FRESH_PATH\"" >> "$FRESH_PATH/build.new/shell.sh"
echo "$fresh_path" >> "$FRESH_PATH/build.new/shell.sh"
__FRESH_PREAMBLE_DONE__=1
fi

}

_dsl_install_fresh() {
Expand Down