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

Support for fish #126

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
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
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
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
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