follow shell script best practices: https://sharats.me/posts/shell-script-best-practices/
This commit is contained in:
parent
04c6fda779
commit
53bfb59c3b
2 changed files with 66 additions and 33 deletions
76
arch.sh
76
arch.sh
|
@ -1,9 +1,19 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if grep "archlinux" /proc/version > /dev/null;
|
||||
then
|
||||
set -o errexit # crash the script when a command crash
|
||||
set -o pipefail # same as above
|
||||
set -o nounset # crash when a variable doesnt exist
|
||||
|
||||
# TRACE=1 for debug
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")" # change script directory
|
||||
|
||||
main() {
|
||||
# === Remove extra packages ==
|
||||
pacman -D --asexplicit archlinux-keyring # Keep this package
|
||||
pacman -D --asexplicit archlinux-keyring # keep this package
|
||||
pacman -Rsn epiphany gnome-maps cheese gnome-weather gnome-music gnome-books vim gnome-boxes gnome-photos malcontent gnome-contacts totem gedit "$(pacman -Qqtd)" --noconfirm
|
||||
# gnome-firefox, maps, caméra, météo, musique, liseuse, vim, machines, photos, parental control, contacts, vidéos, dependencies
|
||||
|
||||
|
@ -112,6 +122,7 @@ then
|
|||
fish -c "abbr yay-rebuild 'checkrebuild | awk \'{print \$2}\' | xargs -r yay -S --rebuildtree --noconfirm'"
|
||||
fish -c "abbr pacman-clean 'sudo pacman -Rsn \$(pacman -Qqtd) --noconfirm'"
|
||||
# Fish by default in terminal app
|
||||
local profil
|
||||
profil=$(gsettings get org.gnome.Terminal.ProfilesList list)
|
||||
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${profil:2:-2}"/ use-custom-command true
|
||||
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:"${profil:2:-2}"/ custom-command "fish"
|
||||
|
@ -168,9 +179,10 @@ then
|
|||
cargo install tealdeer
|
||||
tldr --update
|
||||
# Fish completion
|
||||
latest=$(wget -qO- https://api.github.com/repos/dbrgn/tealdeer/releases/latest)
|
||||
url=$(grep 'browser_download_url": ".*/completions_fish"' <<< "$latest" | awk "{ print substr ($0, 32 ) }" | awk "{ print substr( $0, 1, length($0)-1 ) }")
|
||||
wget -q --show-progress "$url" -O completions_fish
|
||||
local latest_tldr url_tldr
|
||||
latest_tldr=$(wget -qO- https://api.github.com/repos/dbrgn/tealdeer/releases/latest)
|
||||
url_tldr=$(grep 'browser_download_url": ".*/completions_fish"' <<< "$latest_tldr" | awk "{ print substr ($0, 32 ) }" | awk "{ print substr( $0, 1, length($0)-1 ) }")
|
||||
wget -q --show-progress "$url_tldr" -O completions_fish
|
||||
mv completions_fish ~/.config/fish/completions/tldr.fish
|
||||
|
||||
# === Spotify no-ads mod ==
|
||||
|
@ -202,14 +214,15 @@ then
|
|||
wget -q --show-progress https://git.kennel.ml/Anri/confOS/raw/branch/main/.config/flameshot/flameshot.ini -P "$HOME"/.config/flameshot/
|
||||
# Change keybindings
|
||||
gsettings set org.gnome.shell.keybindings show-screenshot-ui "[]"
|
||||
CUSTOM_KEYBINDINGS_LIST=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if [[ $CUSTOM_KEYBINDINGS_LIST == "@as []" ]] # creating new list if not exists
|
||||
local custom_keybindings_list
|
||||
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists
|
||||
then
|
||||
CUSTOM_KEYBINDINGS_LIST="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/']"
|
||||
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/']"
|
||||
else # if already existing, adding our new element
|
||||
CUSTOM_KEYBINDINGS_LIST="${CUSTOM_KEYBINDINGS_LIST::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/']"
|
||||
custom_keybindings_list="${custom_keybindings_list::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/']"
|
||||
fi
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$CUSTOM_KEYBINDINGS_LIST"
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list"
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/ name "Flameshot" # set name
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/ command "flameshot gui" # set command
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/flameshot-shortcut/ binding "Print" # set key
|
||||
|
@ -219,17 +232,17 @@ then
|
|||
rm "$HOME"/.config/gazatu.xyz/emoji-picker.ini 2>/dev/null
|
||||
wget -q --show-progress https://git.kennel.ml/Anri/confOS/raw/branch/main/.config/gazatu.xyz/emoji-picker.ini -P "$HOME"/.config/gazatu.xyz/
|
||||
# Add keybinding
|
||||
CUSTOM_KEYBINDINGS_LIST=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if ! echo "$CUSTOM_KEYBINDINGS_LIST" | grep -q "x11-emoji-picker"
|
||||
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if ! echo "$custom_keybindings_list" | grep -q "x11-emoji-picker"
|
||||
then
|
||||
if [ "$CUSTOM_KEYBINDINGS_LIST" = "@as []" ] # creating new list if not exists
|
||||
if [ "$custom_keybindings_list" = "@as []" ] # creating new list if not exists
|
||||
then
|
||||
CUSTOM_KEYBINDINGS_LIST="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/']"
|
||||
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/']"
|
||||
else # if already existing, adding our new element
|
||||
CUSTOM_KEYBINDINGS_LIST=$(echo "$CUSTOM_KEYBINDINGS_LIST" | sed "s/\[//" | sed "s/\]//")
|
||||
CUSTOM_KEYBINDINGS_LIST="[$CUSTOM_KEYBINDINGS_LIST, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/']"
|
||||
custom_keybindings_list=$(echo "$custom_keybindings_list" | sed "s/\[//" | sed "s/\]//")
|
||||
custom_keybindings_list="[$custom_keybindings_list, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/']"
|
||||
fi
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$CUSTOM_KEYBINDINGS_LIST" # update the list
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" # update the list
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/ name "Emoji-Picker" # set name
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/ command "emoji-picker" # set command
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/x11-emoji-picker/ binding "<Super>period" # set shortcut
|
||||
|
@ -250,14 +263,14 @@ then
|
|||
gnome-extensions enable AlphabeticalAppGrid@stuarthayhurst
|
||||
|
||||
# Nautilus keybinding
|
||||
CUSTOM_KEYBINDINGS_LIST=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if [[ $CUSTOM_KEYBINDINGS_LIST == "@as []" ]] # creating new list if not exists
|
||||
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists
|
||||
then
|
||||
CUSTOM_KEYBINDINGS_LIST="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/']"
|
||||
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/']"
|
||||
else # if already existing, adding our new element
|
||||
CUSTOM_KEYBINDINGS_LIST="${CUSTOM_KEYBINDINGS_LIST::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/']"
|
||||
custom_keybindings_list="${custom_keybindings_list::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/']"
|
||||
fi
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$CUSTOM_KEYBINDINGS_LIST" # updating the list
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" # updating the list
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/ name "Nautilus" # set name
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/ command "nautilus -w" # set command
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/nautilus-shortcut/ binding "<Super>E" # set shortcut
|
||||
|
@ -299,14 +312,14 @@ then
|
|||
|
||||
# === Clipboard manager ==
|
||||
gsettings set org.gnome.shell.keybindings toggle-message-tray "[]"
|
||||
CUSTOM_KEYBINDINGS_LIST=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if [[ $CUSTOM_KEYBINDINGS_LIST == "@as []" ]] # creating new list if not exists
|
||||
custom_keybindings_list=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
|
||||
if [[ $custom_keybindings_list == "@as []" ]] # creating new list if not exists
|
||||
then
|
||||
CUSTOM_KEYBINDINGS_LIST="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/']"
|
||||
custom_keybindings_list="['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/']"
|
||||
else # if already existing, adding our new element
|
||||
CUSTOM_KEYBINDINGS_LIST="${CUSTOM_KEYBINDINGS_LIST::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/']"
|
||||
custom_keybindings_list="${custom_keybindings_list::-1}, '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/']"
|
||||
fi
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$CUSTOM_KEYBINDINGS_LIST" # updating the list
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$custom_keybindings_list" # updating the list
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/ name "Copyq" # set name
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/ command "copyq show" # set command
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/clipboard-shortcut/ binding "<Super>V" # set shortcut
|
||||
|
@ -396,6 +409,11 @@ then
|
|||
sudo cpanm YAML::Tiny File::HomeDir
|
||||
|
||||
echo -e "\nInstallation terminée.\nIl faut redémarrer l'ordinateur."
|
||||
}
|
||||
|
||||
if grep "archlinux" /proc/version > /dev/null;
|
||||
then
|
||||
main "$@"
|
||||
else
|
||||
echo "Ce script ne fonctionne que sur Arch."
|
||||
echo "Ce script ne fonctionne que sur Arch." >&2
|
||||
fi
|
||||
|
|
21
arch_wsl.sh
21
arch_wsl.sh
|
@ -1,7 +1,17 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if grep "WSL2" /proc/version > /dev/null;
|
||||
then
|
||||
set -o errexit # crash the script when a command crash
|
||||
set -o pipefail # same as above
|
||||
set -o nounset # crash when a variable doesnt exist
|
||||
|
||||
# TRACE=1 for debug
|
||||
if [[ "${TRACE-0}" == "1" ]]; then
|
||||
set -o xtrace
|
||||
fi
|
||||
|
||||
cd "$(dirname "$0")" # change script directory
|
||||
|
||||
main() {
|
||||
# === Init pacman ==
|
||||
pacman-key --init
|
||||
pacman-key --populate
|
||||
|
@ -165,6 +175,7 @@ then
|
|||
cargo install tealdeer
|
||||
tldr --update
|
||||
# Fish completion
|
||||
local latest_tldr url_tldr
|
||||
latest_tldr=$(wget -qO- https://api.github.com/repos/dbrgn/tealdeer/releases/latest)
|
||||
url_tldr=$(grep 'browser_download_url": ".*/completions_fish"' <<< "$latest_tldr" | awk "{ print substr ($0, 32 ) }" | awk "{ print substr( $0, 1, length($0)-1 ) }")
|
||||
wget -q --show-progress "$url_tldr" -O completions_fish
|
||||
|
@ -232,7 +243,11 @@ then
|
|||
echo " - Jeu de couleur = One Half Dark"
|
||||
echo " - Type de police = Caskaydia Cove Nerd Font Complete Mono Windows Compatible"
|
||||
echo " (à télécharger ici : https://www.nerdfonts.com/font-downloads)"
|
||||
}
|
||||
|
||||
if grep "WSL2" /proc/version > /dev/null;
|
||||
then
|
||||
main "$@"
|
||||
else
|
||||
echo "Ce script ne fonctionne que sur ArchWSL."
|
||||
echo "Ce script ne fonctionne que sur ArchWSL." >&2
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue