automatically add alias to .bashrc (support zsh and fish too)
This commit is contained in:
parent
8dcd514fa3
commit
ddce1128cd
2 changed files with 63 additions and 39 deletions
41
README.md
41
README.md
|
@ -1,44 +1,25 @@
|
||||||
# Téléchargement et utilisation
|
# Téléchargement et utilisation
|
||||||
|
|
||||||
- Téléchargez [`updateVSCodium.sh`](https://gitlab.com/Mylloon/downloadcodium/-/raw/main/updateVSCodium.sh?inline=false) et lancez-le (`bash updateVSCodium.sh`).
|
- Lancez cette commande :
|
||||||
|
Va télécharger le script, et le lancer tout seul, en se supprimant à la fin de l'éxécution.
|
||||||
|
```bash
|
||||||
|
wget -q --show-progress https://git.kennel.ml/Anri/downloadcodium/raw/branch/main/updateVSCodium.sh -O tmp.sh && bash tmp.sh; rm tmp.sh
|
||||||
|
```
|
||||||
|
ou
|
||||||
|
- Téléchargez [`updateVSCodium.sh`](https://git.kennel.ml/Anri/downloadcodium/raw/branch/main/updateVSCodium.sh) et lancez-le (`bash updateVSCodium.sh`).
|
||||||
|
|
||||||
Résultat :
|
Pour lancer depuis `~/.vscodium_scripts` :
|
||||||
```
|
- `./VSCodium.AppImage --no-sandbox`
|
||||||
you@machine:~$ chmod u+x updateVSCodium.sh
|
|
||||||
you@machine:~$ ./updateVSCodium.sh
|
|
||||||
VSCodium.AppImage 100%[=================================================>] 109,72M 303KB/s in 16s
|
|
||||||
```
|
|
||||||
|
|
||||||
Pour lancer :
|
|
||||||
|
|
||||||
`./VSCodium.AppImage --no-sandbox`
|
|
||||||
|
|
||||||
## Utilité
|
## Utilité
|
||||||
|
|
||||||
Script pour télécharger codium version portable en une ligne :
|
Script pour télécharger codium version portable en une ligne :
|
||||||
- mettre à jour sans devoir aller sur github à chaque fois
|
- mettre à jour sans devoir aller sur github à chaque fois
|
||||||
- télécharge toujours au même endroit peut importe l'emplacement du script
|
|
||||||
- ferme et/ou remplace automatiquement codium au lancement si ouvert et/ou présent
|
- ferme et/ou remplace automatiquement codium au lancement si ouvert et/ou présent
|
||||||
|
- Commandes simples ajouté à bash, zsh et fish pour permettre d'utiliser et de mettre-à-jour Codium.
|
||||||
## Exemple de raccourci
|
|
||||||
Par exemple si le script est rangé dans `~/.secret`.
|
|
||||||
|
|
||||||
### Avec Bash / ZSH
|
|
||||||
Dans `~/.bashrc` ou `~/.zshrc` :
|
|
||||||
```bash
|
|
||||||
alias updateCodium="$HOME/.secret/downloadVSCodium.sh"
|
|
||||||
alias code="$HOME/VSCodium.AppImage --no-sandbox"
|
|
||||||
```
|
|
||||||
|
|
||||||
### Avec Fish
|
|
||||||
Dans `~/.config/fish/config.fish` :
|
|
||||||
```bash
|
|
||||||
abbr updateCodium '$HOME/.secret/downloadVSCodium.sh'
|
|
||||||
abbr code '$HOME/VSCodium.AppImage --no-sandbox'
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
Après ça, redémarrez votre shell et écrivez `updateCodium` pour mettre-à-jour/installer Codium.
|
A l'avenir pour mettre à jour Codium, lancez `updateCodium`.
|
||||||
|
|
||||||
|
|
||||||
## Avoir des extensions utile même avec Codium
|
## Avoir des extensions utile même avec Codium
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# retrieve latest vscodium package
|
# The goal is :
|
||||||
wget -q https://api.github.com/repos/VSCodium/vscodium/releases/latest
|
# -> to create a folder ".vscodium_scripts"
|
||||||
grep 'browser_download_url": ".*.AppImage"' latest | awk '{ print substr ($0, 32 ) }' | awk '{ print substr( $0, 1, length($0)-1 ) }' > url
|
# at $HOME who have this script and the .AppImage
|
||||||
rm latest
|
#
|
||||||
|
# -> to create some shortcut "code" for codium
|
||||||
|
# and "updateCodium" to relaunch this script
|
||||||
|
# and update codium
|
||||||
|
|
||||||
# kill codium if already running
|
# kill codium if already running
|
||||||
if pgrep -f "codium" > /dev/null
|
if pgrep -f "codium" > /dev/null
|
||||||
|
@ -11,8 +14,46 @@ then
|
||||||
pkill -9 codium
|
pkill -9 codium
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# remove VSCodium package if already exists
|
if [ -x $HOME/.vscodium_scripts ] ; then # if the folder already exists (not the first run?)
|
||||||
[ -f $HOME/VSCodium.AppImage ] && rm $HOME/VSCodium.AppImage
|
# remove the folder
|
||||||
|
rm -r $HOME/.vscodium_scripts
|
||||||
|
|
||||||
|
else # if the folder isn't already created (first run?)
|
||||||
|
|
||||||
|
#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 if exists
|
||||||
|
if [ -f $HOME/.bashrc ] ; then
|
||||||
|
echo "alias updateCodium='$HOME/.vscodium_scripts/downloadVSCodium.sh'" >> $HOME/.bashrc
|
||||||
|
echo "alias code='$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox'" >> $HOME/.bashrc
|
||||||
|
fi
|
||||||
|
# to .zshrc if exists
|
||||||
|
if [ -f $HOME/.zshrc ] ; then
|
||||||
|
echo "alias updateCodium='$HOME/.vscodium_scripts/downloadVSCodium.sh'" >> $HOME/.zshrc
|
||||||
|
echo "alias code='$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox'" >> $HOME/.zshrc
|
||||||
|
fi
|
||||||
|
# to config.fish if exists
|
||||||
|
if [ -f $HOME/.config/fish/config.fish ] ; then
|
||||||
|
echo "abbr updateCodium '$HOME/.vscodium_scripts/downloadVSCodium.sh'" >> $HOME/.config/fish/config.fish
|
||||||
|
echo "abbr code '$HOME/.vscodium_scripts/VSCodium.AppImage --no-sandbox'" >> $HOME/.config/fish/config.fish
|
||||||
|
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
|
||||||
|
|
||||||
# download the latest vscodium AppImage
|
# download the latest vscodium AppImage
|
||||||
wget -q --show-progress -i url -O VSCodium.AppImage
|
wget -q --show-progress -i url -O VSCodium.AppImage
|
||||||
|
@ -21,8 +62,10 @@ rm url
|
||||||
# make it executable
|
# make it executable
|
||||||
chmod u+x VSCodium.AppImage
|
chmod u+x VSCodium.AppImage
|
||||||
|
|
||||||
# moving it to the home folder
|
|
||||||
[ -f $HOME/VSCodium.AppImage ] || mv VSCodium.AppImage $HOME/VSCodium.AppImage
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "VSCodium is now downloaded at $HOME/VSCodium.AppImage."
|
# not really installed because no packet manager know what happened
|
||||||
|
echo "VSCodium is now downloaded and \"installed*\" at $PWD/VSCodium.AppImage."
|
||||||
|
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"
|
||||||
|
|
Reference in a new issue