Allow to install to $HOME without sudo #28

wget -qO- https://git.io/papirus-folders-install | env PREFIX=$HOME/.local sh
This commit is contained in:
Sergei Eremenko 2022-07-25 18:09:20 +03:00
parent 86c63fdd21
commit 6837aa9ca9
No known key found for this signature in database
GPG key ID: AB6D54C1C16D2507
2 changed files with 22 additions and 8 deletions

View file

@ -55,6 +55,12 @@ Use the script to install the latest version directly from this repo (independen
wget -qO- https://git.io/papirus-folders-install | sh
```
To install papirus-folders to **home directory** using the following command:
```
wget -qO- https://git.io/papirus-folders-install | env PREFIX=$HOME/.local sh
```
To install papirus-folders on **BSD systems** using the following command:
```

View file

@ -36,10 +36,18 @@ _msg() {
echo "=>" "$@"
}
_sudo() {
if [ -w "$PREFIX" ] || [ -w "$(dirname "$PREFIX")" ]; then
"$@"
else
sudo "$@"
fi
}
_rm() {
# removes parent directories if empty
sudo rm -rf "$1"
sudo rmdir -p "$(dirname "$1")" 2>/dev/null || true
_sudo rm -rf "$1"
_sudo rmdir -p "$(dirname "$1")" 2>/dev/null || true
}
_download() {
@ -63,17 +71,17 @@ _install() {
tag="${TAG#v}"
_msg "Installing ..."
sudo mkdir -p "$PREFIX/bin"
sudo install -m 755 "$temp_dir/$gh_repo-$tag/$bin_name" \
_sudo mkdir -p "$PREFIX/bin"
_sudo install -m 755 "$temp_dir/$gh_repo-$tag/$bin_name" \
"$PREFIX/bin/$bin_name"
sudo mkdir -p "$PREFIX/share/bash-completion/completions"
sudo install -m 644 "$temp_dir/$gh_repo-$tag/completion/$bin_name" \
_sudo mkdir -p "$PREFIX/share/bash-completion/completions"
_sudo install -m 644 "$temp_dir/$gh_repo-$tag/completion/$bin_name" \
"$PREFIX/share/bash-completion/completions"
if [ -d "$PREFIX/share/zsh/site-functions" ]; then
sudo install -m 644 "$temp_dir/$gh_repo-$tag/completion/_$bin_name" \
_sudo install -m 644 "$temp_dir/$gh_repo-$tag/completion/_$bin_name" \
"$PREFIX/share/zsh/site-functions"
elif [ -d "$PREFIX/share/zsh/vendor-completions" ]; then
sudo install -m 644 "$temp_dir/$gh_repo-$tag/completion/_$bin_name" \
_sudo install -m 644 "$temp_dir/$gh_repo-$tag/completion/_$bin_name" \
"$PREFIX/share/zsh/vendor-completions"
else :
fi