mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 12:29:40 -08:00
feat(install): use user-writable installation directories by default
relates to #5284
This commit is contained in:
parent
024c8b6ed5
commit
55113b8e66
|
@ -24,7 +24,7 @@ help() {
|
|||
echo "Syntax: install.sh [-h|d|t]"
|
||||
echo "options:"
|
||||
echo "-h Print this help."
|
||||
echo "-d Specify the installation directory. Defaults to /usr/local/bin or the directory where oh-my-posh is installed."
|
||||
echo "-d Specify the installation directory. Defaults to $HOME/bin, $HOME/.local/bin or the directory where oh-my-posh is installed."
|
||||
echo "-t Specify the themes installation directory. Defaults to the oh-my-posh cache directory."
|
||||
echo
|
||||
}
|
||||
|
@ -74,9 +74,22 @@ set_install_directory() {
|
|||
install_dir=$(dirname $real_dir)
|
||||
info "Oh My Posh is already installed, updating existing installation in:"
|
||||
info " ${install_dir}"
|
||||
else
|
||||
install_dir="/usr/local/bin"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# check if $HOME/bin exists and is writable
|
||||
if [ -d "$HOME/bin" ] && [ -w "$HOME/bin" ]; then
|
||||
install_dir="$HOME/bin"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# check if $HOME/.local/bin exists and is writable
|
||||
if ([ -d "$HOME/.local/bin" ] && [ -w "$HOME/.local/bin" ]) || mkdir "$HOME/.local/bin"; then
|
||||
install_dir="$HOME/.local/bin"
|
||||
return 0
|
||||
fi
|
||||
|
||||
error "Cannot determine installation directory. Please specify a directory and try again: \ncurl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory}"
|
||||
}
|
||||
|
||||
validate_install_directory() {
|
||||
|
@ -102,7 +115,7 @@ validate_install_directory() {
|
|||
)
|
||||
|
||||
if [ "${good}" != "1" ]; then
|
||||
warn "Installation directory ${install_dir} is not in your \$PATH"
|
||||
warn "Installation directory ${install_dir} is not in your \$PATH, add it using \nexport PATH=\$PATH:${install_dir}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue