Last active
March 7, 2023 01:41
-
-
Save dragonman225/b2e96950cd3d1cfd1ee117b1b88b3df6 to your computer and use it in GitHub Desktop.
Typora Install Script for Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Typora Installer by dragonman225 | |
# Variables | |
USER=$(/usr/bin/id -run) | |
INSTALL_DIR="${HOME}/applications" | |
APP_SHORTCUT="/usr/share/applications/typora.desktop" | |
TYPORA_ARCHIVE="/tmp/Typora-linux-x64.tar.gz" | |
# Greeting | |
echo "Typora Installer by dragonman225" | |
echo "Start installing Typora to ${INSTALL_DIR}" | |
read -p "Continue? (yY/nN)" -r | |
if [[ ${REPLY} =~ ^[Yy]$ ]] | |
then | |
# Make sure install directory exists | |
if [ ! -d ${INSTALL_DIR} ]; then | |
mkdir -p ${INSTALL_DIR} | |
fi | |
# Download Typora | |
echo -e "Downloading Typora..." | |
curl https://typora.io/linux/Typora-linux-x64.tar.gz -o ${TYPORA_ARCHIVE} | |
# Extract Typora | |
echo -e "Extracting Typora to ${INSTALL_DIR} ..." | |
if [ -d ${INSTALL_DIR}/typora ]; then | |
echo "Typora exists. Remove for fresh install ..." | |
rm -rf ${INSTALL_DIR}/typora | |
fi | |
tar -xzf ${TYPORA_ARCHIVE} --strip-components=1 -C ${INSTALL_DIR} | |
mv ${INSTALL_DIR}/Typora-linux-x64 ${INSTALL_DIR}/typora | |
chown -R ${USER}:${USER} ${INSTALL_DIR}/typora | |
rm ${TYPORA_ARCHIVE} | |
# Create Desktop Entry | |
if [ ! -d ${APP_SHORTCUT_DIR} ]; then | |
mkdir -p ${APP_SHORTCUT_DIR} | |
fi | |
echo "Creating Desktop Entry at ${APP_SHORTCUT} ..." | |
sudo bash -c "cat <<- EOF > ${APP_SHORTCUT} | |
[Desktop Entry] | |
Type=Application | |
Encoding=UTF-8 | |
Name=Typora | |
Comment=Markdown Editor | |
Exec=${INSTALL_DIR}/typora/Typora %F | |
Icon=${INSTALL_DIR}/typora/resources/app/asserts/icon/icon_256x256.png | |
Terminal=false | |
EOF" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment