Skip to content

Commit daa41ac

Browse files
committed
Print PATH instructions after install
1 parent dd44df6 commit daa41ac

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

install.sh

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,11 @@ case "$os" in
7171
esac
7272

7373
if [ -z "$PREFIX" ]; then
74-
case "$os" in
75-
Darwin)
76-
if [ -d "/opt/homebrew/bin" ] && [ -w "/opt/homebrew/bin" ]; then
77-
PREFIX="/opt/homebrew/bin"
78-
elif [ -d "/usr/local/bin" ] && [ -w "/usr/local/bin" ]; then
79-
PREFIX="/usr/local/bin"
80-
elif [ "$(id -u)" -eq 0 ]; then
81-
PREFIX="/usr/local/bin"
82-
else
83-
PREFIX="${HOME}/.local/bin"
84-
fi
85-
;;
86-
*)
87-
if [ "$(id -u)" -eq 0 ]; then
88-
PREFIX="/usr/local/bin"
89-
else
90-
PREFIX="${HOME}/.local/bin"
91-
fi
92-
;;
93-
esac
74+
if [ "$(id -u)" -eq 0 ]; then
75+
PREFIX="/usr/local/bin"
76+
else
77+
PREFIX="${HOME}/.local/bin"
78+
fi
9479
fi
9580

9681
mkdir -p "$PREFIX"
@@ -137,10 +122,24 @@ chmod 755 "$install_bin"
137122

138123
echo "Installed anycode to $install_bin"
139124

140-
case ":$PATH:" in
141-
*":$PREFIX:"*)
142-
;;
143-
*)
144-
echo "Add $PREFIX to your PATH if it is not there yet."
145-
;;
146-
esac
125+
if command -v anycode >/dev/null 2>&1; then
126+
echo "anycode is already available in PATH."
127+
else
128+
echo "anycode is not in PATH yet."
129+
shell_name="$(basename "${SHELL:-}")"
130+
case "$shell_name" in
131+
zsh)
132+
rc_file="${HOME}/.zshrc"
133+
;;
134+
bash)
135+
rc_file="${HOME}/.bashrc"
136+
;;
137+
*)
138+
rc_file="${HOME}/.profile"
139+
;;
140+
esac
141+
echo "Run this command to add it:"
142+
echo " echo 'export PATH=\"$PREFIX:\$PATH\"' >> \"$rc_file\""
143+
echo "Then restart your shell or run:"
144+
echo " export PATH=\"$PREFIX:\$PATH\""
145+
fi

0 commit comments

Comments
 (0)