This repository has been archived on 2023-12-11. You can view files and clone it, but cannot push or open issues or pull requests.
downloadcodium/updateVSCodium.sh

84 lines
2.9 KiB
Bash
Raw Permalink Normal View History

2021-10-21 19:55:41 +02:00
#!/usr/bin/env bash
# The goal is :
# -> to create a folder ".vscodium_scripts"
# at $HOME who have this script and the .AppImage
#
# -> to create some shortcut "code" for codium
# and "updateCodium" to relaunch this script
# and update codium
# kill codium if already running
if pgrep -f "codium" > /dev/null
then
pkill -9 codium
fi
2023-02-07 15:40:29 +01:00
if [ -x "$HOME"/.vscodium_scripts ] ; then # if the folder already exists (not the first run?)
2021-11-18 12:13:14 +01:00
# go to the folder and clear it
2023-02-07 15:40:29 +01:00
cd "$HOME/.vscodium_scripts" || exit
rm ./*
else # if the folder isn't already created (first run?)
2021-11-18 12:13:14 +01:00
# creating the folder
2023-02-07 15:40:29 +01:00
mkdir "$HOME/".vscodium_scripts
cd "$HOME"/.vscodium_scripts || exit
2021-11-14 17:26:13 +01:00
echo ""
2021-11-14 16:53:27 +01:00
echo "First run, adding commmands to shell, you will need to restart your shell"
echo "to use theses commands : \`code\` for Codium and \`updateCodium\` to update it."
# adding code command and updateCodium command
# to all the shell installed
# to .bashrc (i assume it always exists, anyways if not this script is hard to start
# because all the alias/abbr are using bash)
2023-02-07 15:40:29 +01:00
{
echo ""
echo "# Alias for Codium"
echo "alias updateCodium='bash \$HOME/.vscodium_scripts/updateVSCodium.sh'"
echo "alias code='\$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox > /dev/null 2>&1 & disown'"
echo ""
} >> "$HOME"/.bashrc
2021-11-14 19:45:25 +01:00
# to .zshrc if exists
2023-02-07 15:40:29 +01:00
if [ -f "$HOME"/.zshrc ] ; then
{
echo ""
echo "# Alias for Codium"
echo "alias updateCodium='bash \$HOME/.vscodium_scripts/updateVSCodium.sh'"
echo "alias code='\$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox > /dev/null 2>&1 & disown'"
echo ""
} >> "$HOME"/.zshrc
fi
2021-11-14 19:45:25 +01:00
# if config.fish exists
2023-02-07 15:40:29 +01:00
if [ -f "$HOME"/.config/fish/config.fish ] ; then
2021-11-14 19:45:25 +01:00
fish -c "abbr updateCodium 'bash \$HOME/.vscodium_scripts/updateVSCodium.sh'"
2021-11-18 12:49:49 +01:00
fish -c "abbr code 'bash \$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox > /dev/null 2>&1 & disown'"
fi
fi
# downloading this script in the folder
2023-02-07 15:37:48 +01:00
wget -q --show-progress https://git.mylloon.fr/Anri/downloadcodium/raw/branch/main/updateVSCodium.sh
# retrieve latest vscodium package url
wget -q https://api.github.com/repos/VSCodium/vscodium/releases/latest
grep 'browser_download_url": ".*.AppImage"' latest | awk '{ print substr ($0, 32 ) }' | awk '{ print substr( $0, 1, length($0)-1 ) }' > url
rm latest
# download the latest vscodium AppImage
2021-10-21 19:55:41 +02:00
wget -q --show-progress -i url -O VSCodium.AppImage
rm url
# make it executable
2021-10-21 19:55:41 +02:00
chmod u+x VSCodium.AppImage
echo ""
# not really installed because no packet manager know what happened
echo "VSCodium is now downloaded and \"installed*\" at $PWD/VSCodium.AppImage."
2021-11-14 16:53:27 +01:00
#echo "You need to restart your shell to use all the new commands."
echo "\`updateCodium\` -> update Codium to the latest version"
echo "\`code\` -> start Codium"