2021-10-21 19:55:41 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-11-14 16:51:16 +01:00
|
|
|
# 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
|
2021-11-14 16:20:09 +01:00
|
|
|
|
|
|
|
# kill codium if already running
|
2021-10-21 19:58:04 +02:00
|
|
|
if pgrep -f "codium" > /dev/null
|
|
|
|
then
|
|
|
|
pkill -9 codium
|
|
|
|
fi
|
2021-11-14 16:20:09 +01:00
|
|
|
|
2021-11-14 16:51:16 +01:00
|
|
|
if [ -x $HOME/.vscodium_scripts ] ; then # if the folder already exists (not the first run?)
|
|
|
|
# remove the folder
|
|
|
|
rm -r $HOME/.vscodium_scripts
|
|
|
|
|
|
|
|
else # if the folder isn't already created (first run?)
|
|
|
|
|
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."
|
2021-11-14 16:51:16 +01:00
|
|
|
|
|
|
|
# adding code command and updateCodium command
|
|
|
|
# to all the shell installed
|
|
|
|
|
2021-11-14 17:19:37 +01:00
|
|
|
# to .bashrc (i assume it always exists, anyways if not this script is hard to start
|
|
|
|
# because all the alias/abbr are using bash)
|
|
|
|
echo "" >> $HOME/.bashrc
|
|
|
|
echo "# Alias for Codium" >> $HOME/.bashrc
|
|
|
|
echo "alias updateCodium='bash \$HOME/.vscodium_scripts/updateVSCodium.sh'" >> $HOME/.bashrc
|
|
|
|
echo "alias code='bash \$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox > /dev/null 2>&1 &;disown'" >> $HOME/.bashrc
|
2021-11-14 17:20:10 +01:00
|
|
|
echo "" >> $HOME/.bashrc
|
2021-11-14 17:19:37 +01:00
|
|
|
|
2021-11-14 16:51:16 +01:00
|
|
|
# to .zshrc if exists
|
|
|
|
if [ -f $HOME/.zshrc ] ; then
|
2021-11-14 17:00:57 +01:00
|
|
|
echo "" >> $HOME/.zshrc
|
|
|
|
echo "# Alias for Codium" >> $HOME/.zshrc
|
2021-11-14 17:16:14 +01:00
|
|
|
echo "alias updateCodium='bash \$HOME/.vscodium_scripts/updateVSCodium.sh'" >> $HOME/.zshrc
|
|
|
|
echo "alias code='bash \$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox > /dev/null 2>&1 &;disown'" >> $HOME/.zshrc
|
2021-11-14 17:20:10 +01:00
|
|
|
echo "" >> $HOME/.zshrc
|
2021-11-14 16:51:16 +01:00
|
|
|
fi
|
2021-11-14 17:19:37 +01:00
|
|
|
|
2021-11-14 16:51:16 +01:00
|
|
|
# to config.fish if exists
|
|
|
|
if [ -f $HOME/.config/fish/config.fish ] ; then
|
2021-11-14 17:00:57 +01:00
|
|
|
echo "" >> $HOME/.config/fish/config.fish
|
|
|
|
echo "# Abbrevations for Codium" >> $HOME/.config/fish/config.fish
|
2021-11-14 17:16:14 +01:00
|
|
|
echo "abbr updateCodium 'bash \$HOME/.vscodium_scripts/updateVSCodium.sh'" >> $HOME/.config/fish/config.fish
|
|
|
|
echo "abbr code 'bash \$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox > /dev/null 2>&1 &;disown'" >> $HOME/.config/fish/config.fish
|
2021-11-14 17:20:10 +01:00
|
|
|
echo "" >> $HOME/.config/fish/config.fish
|
2021-11-14 16:51:16 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# (re)creating the folder
|
|
|
|
mkdir $HOME/.vscodium_scripts
|
|
|
|
cd $HOME/.vscodium_scripts
|
|
|
|
|
|
|
|
# downloading this script in the folder
|
|
|
|
wget -q --show-progress https://git.kennel.ml/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
|
2021-11-14 16:20:09 +01:00
|
|
|
|
|
|
|
# download the latest vscodium AppImage
|
2021-10-21 19:55:41 +02:00
|
|
|
wget -q --show-progress -i url -O VSCodium.AppImage
|
|
|
|
rm url
|
2021-11-14 16:20:09 +01:00
|
|
|
|
|
|
|
# make it executable
|
2021-10-21 19:55:41 +02:00
|
|
|
chmod u+x VSCodium.AppImage
|
2021-11-14 16:20:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
echo ""
|
2021-11-14 16:51:16 +01:00
|
|
|
# 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"
|