mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -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() {
|
||||
|
@ -84,7 +97,7 @@ validate_install_directory() {
|
|||
if [ ! -d "$install_dir" ]; then
|
||||
error "Directory ${install_dir} does not exist, set a different directory and try again."
|
||||
fi
|
||||
|
||||
|
||||
# Check if regular user has write permission
|
||||
if [ ! -w "$install_dir" ]; then
|
||||
error "Cannot write to ${install_dir}. Please check write permissions or set a different directory and try again: \ncurl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory}"
|
||||
|
@ -102,12 +115,12 @@ 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
|
||||
}
|
||||
|
||||
validate_themes_directory() {
|
||||
|
||||
|
||||
# Validate if the themes directory exists
|
||||
if ! mkdir -p "$themes_dir" > /dev/null 2>&1; then
|
||||
error "Cannot write to ${themes_dir}. Please check write permissions or set a different directory and try again: \ncurl -s https://ohmyposh.dev/install.sh | bash -s -- -t {directory}"
|
||||
|
|
Loading…
Reference in a new issue