Skip to content

Commit

Permalink
support for installation on MacOS/zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
Lifailon committed Dec 10, 2024
1 parent 7beb436 commit ec1a7fd
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

OS=$(uname -s | tr '[:upper:]' '[:lower:]')

ARCH=$(uname -m)
case $ARCH in
x86_64|amd64) ARCH="amd64" ;;
Expand All @@ -11,17 +13,29 @@ case $ARCH in
;;
esac

if [ $SHELL = "/bin/bash" ]; then
shellRc="$HOME/.bashrc"
elif [ $SHELL = "/bin/zsh" ]; then
shellRc="$HOME/.zshrc"
else
echo -e "\033[31mError.\033[0m Shell not supported: $SHELL"
echo -e "Create a request with a \033[31mproblem\033[0m: https://github.com/Lifailon/lazyjournal/issues"
exit 1
fi

touch $shellRc
mkdir -p $HOME/.local/bin
grep -F 'export PATH=$PATH:$HOME/.local/bin' $HOME/.bashrc > /dev/null || {
echo 'export PATH=$PATH:$HOME/.local/bin' >> $HOME/.bashrc && source $HOME/.bashrc;

grep -F 'export PATH=$PATH:$HOME/.local/bin' $shellRc > /dev/null || {
echo 'export PATH=$PATH:$HOME/.local/bin' >> $shellRc && source $shellRc;
}

GITHUB_LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' https://github.com/Lifailon/lazyjournal/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
if [ -z "$GITHUB_LATEST_VERSION" ]; then
echo -e "\033[31mError.\033[0m Unable to get the latest version from GitHub repository, check your internet connection."
exit 1
else
BIN_URL="https://github.com/Lifailon/lazyjournal/releases/download/$GITHUB_LATEST_VERSION/lazyjournal-$GITHUB_LATEST_VERSION-linux-$ARCH"
BIN_URL="https://github.com/Lifailon/lazyjournal/releases/download/$GITHUB_LATEST_VERSION/lazyjournal-$GITHUB_LATEST_VERSION-$OS-$ARCH"
curl -L -s "$BIN_URL" -o $HOME/.local/bin/lazyjournal
chmod +x $HOME/.local/bin/lazyjournal
echo -e "✔ Installation completed \033[32msuccessfully\033[0m"
Expand Down

0 comments on commit ec1a7fd

Please sign in to comment.