mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 20:09:39 -08:00
chore(install): update install.sh
This commit is contained in:
parent
72acdb764c
commit
d7a33b3de1
|
@ -1,11 +1,11 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
install_dir=""
|
install_dir=""
|
||||||
themes_dir=""
|
themes_dir=""
|
||||||
executable=""
|
executable=""
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
printf "\x1b[31m$1\e[0m\n"
|
printf "\e[31m$1\e[0m\n"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ info() {
|
||||||
}
|
}
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
printf "⚠️ \x1b[33m$1\e[0m\n"
|
printf "⚠️ \e[33m$1\e[0m\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
|
@ -84,9 +84,13 @@ validate_install_directory() {
|
||||||
error "Directory ${install_dir} does not exist, set a different directory and try again."
|
error "Directory ${install_dir} does not exist, set a different directory and try again."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if we can write to the install directory
|
# Check if sudo has write permission
|
||||||
if [ ! -w $install_dir ]; then
|
if ! sudo test -w "$install_dir"; then
|
||||||
error "Cannot write to ${install_dir}. Please set a different directory and try again: \n curl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory}"
|
error "Cannot write to ${install_dir}. Please set a different directory and try again: \n curl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory}"
|
||||||
|
|
||||||
|
# Check if regular user has write permission
|
||||||
|
elif [ ! -w "$install_dir" ]; then
|
||||||
|
error "Cannot write to ${install_dir}. Please set a different directory and try again: \n curl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory} OR use sudo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if the directory is in the PATH
|
# check if the directory is in the PATH
|
||||||
|
@ -110,9 +114,13 @@ validate_themes_directory() {
|
||||||
error "Directory ${install_dir} does not exist, set a different directory and try again."
|
error "Directory ${install_dir} does not exist, set a different directory and try again."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if we can write to the install directory
|
# Check if sudo has write permission
|
||||||
if [ ! -w $install_dir ]; then
|
if ! sudo test -w "$install_dir"; then
|
||||||
error "Cannot write to ${install_dir}. Please set a different directory and try again: \n curl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory}"
|
error "Cannot write to ${install_dir}. Please set a different directory and try again: \n curl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory}"
|
||||||
|
|
||||||
|
# Check if regular user has write permission
|
||||||
|
elif [ ! -w "$install_dir" ]; then
|
||||||
|
error "Cannot write to ${install_dir}. Please set a different directory and try again: \n curl -s https://ohmyposh.dev/install.sh | bash -s -- -d {directory} OR use sudo"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if the directory is in the PATH
|
# check if the directory is in the PATH
|
||||||
|
@ -157,7 +165,7 @@ install_themes() {
|
||||||
|
|
||||||
http_response=$(curl -s -f -L $url -o $zip_file -w "%{http_code}")
|
http_response=$(curl -s -f -L $url -o $zip_file -w "%{http_code}")
|
||||||
|
|
||||||
if [ $http_response == "200" ] && [ -f $zip_file ]; then
|
if [ $http_response = "200" ] && [ -f $zip_file ]; then
|
||||||
unzip -o -q $zip_file -d $themes_dir
|
unzip -o -q $zip_file -d $themes_dir
|
||||||
# make sure the files are readable and writable for all users
|
# make sure the files are readable and writable for all users
|
||||||
chmod a+rwX ${themes_dir}/*.omp.*
|
chmod a+rwX ${themes_dir}/*.omp.*
|
||||||
|
@ -205,7 +213,7 @@ install() {
|
||||||
|
|
||||||
info "🚀 Installation complete.\n\nYou can follow the instructions at https://ohmyposh.dev/docs/installation/prompt"
|
info "🚀 Installation complete.\n\nYou can follow the instructions at https://ohmyposh.dev/docs/installation/prompt"
|
||||||
info "to setup your shell to use oh-my-posh."
|
info "to setup your shell to use oh-my-posh."
|
||||||
if [ $http_response == "200" ]; then
|
if [ $http_response = "200" ]; then
|
||||||
info "\nIf you want to use a built-in theme, you can find them in the ${theme_dir} directory:"
|
info "\nIf you want to use a built-in theme, you can find them in the ${theme_dir} directory:"
|
||||||
info " oh-my-posh init {shell} --config ${theme_dir}/{theme}.omp.json\n"
|
info " oh-my-posh init {shell} --config ${theme_dir}/{theme}.omp.json\n"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue