mirror of
https://github.com/denisidoro/navi
synced 2024-11-24 20:43:06 +00:00
Respect BIN_DIR in install script (#566)
This commit is contained in:
parent
4c9583bdf2
commit
4ac39e8b9b
1 changed files with 30 additions and 6 deletions
|
@ -9,7 +9,8 @@ fi
|
|||
# paths
|
||||
# =====================
|
||||
|
||||
export BIN_DIR="${BIN_DIR:-"${HOME}/.cargo/bin"}"
|
||||
export CARGO_DEFAULT_BIN="${HOME}/.cargo/bin"
|
||||
export BIN_DIR="${BIN_DIR:-"$CARGO_DEFAULT_BIN"}"
|
||||
|
||||
|
||||
# =====================
|
||||
|
@ -217,7 +218,7 @@ get_shell() {
|
|||
|
||||
export_path_cmd() {
|
||||
echo
|
||||
echo ' export PATH="${PATH}:'"$BIN_DIR"'"'
|
||||
echo ' export PATH="${PATH}:'"$1"'"'
|
||||
}
|
||||
|
||||
append_to_file() {
|
||||
|
@ -228,6 +229,19 @@ append_to_file() {
|
|||
fi
|
||||
}
|
||||
|
||||
get_navi_bin_path() {
|
||||
local file="${BIN_DIR}/navi"
|
||||
if [ -f "$file" ]; then
|
||||
echo "$file"
|
||||
return 0
|
||||
fi
|
||||
file="${CARGO_DEFAULT_BIN}/navi"
|
||||
if [ -f "$file" ]; then
|
||||
echo "$file"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
install_navi() {
|
||||
local -r target="$(get_target)"
|
||||
|
||||
|
@ -250,15 +264,25 @@ install_navi() {
|
|||
|
||||
fi
|
||||
|
||||
hash -r 2>/dev/null || true
|
||||
|
||||
local navi_bin_path="$(which navi || get_navi_bin_path)"
|
||||
ln -s "$navi_bin_path" "${BIN_DIR}/navi" &>/dev/null || true
|
||||
if [ -f "${BIN_DIR}/navi" ]; then
|
||||
navi_bin_path="${BIN_DIR}/navi"
|
||||
fi
|
||||
|
||||
local -r navi_bin_dir="$(dirname "$navi_bin_path")"
|
||||
|
||||
echoerr
|
||||
log::success "Finished"
|
||||
log::success "navi is now available at ${BIN_DIR}/navi"
|
||||
log::success "navi is now available at ${navi_bin_path}"
|
||||
echoerr
|
||||
|
||||
if echo "$PATH" | grep -q "$BIN_DIR"; then
|
||||
if echo "$PATH" | grep -q "$navi_bin_path"; then
|
||||
:
|
||||
else
|
||||
local -r cmd="$(export_path_cmd)"
|
||||
local -r cmd="$(export_path_cmd "$navi_bin_path")"
|
||||
append_to_file "${HOME}/.bashrc" "$cmd"
|
||||
append_to_file "${ZDOTDIR:-"$HOME"}/.zshrc" "$cmd"
|
||||
append_to_file "${HOME}/.fishrc" "$cmd"
|
||||
|
@ -268,7 +292,7 @@ install_navi() {
|
|||
echo
|
||||
log::note "Check https://github.com/denisidoro/navi for more info"
|
||||
|
||||
export PATH="${PATH}:${BIN_DIR}"
|
||||
export PATH="${PATH}:${navi_bin_path}"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue