From c68eb59d99e108c72641b5de97bb465fe7a126a1 Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Fri, 22 Dec 2023 19:07:36 +0100 Subject: [PATCH] Declaraive is more maintainable than imperative. --- .bashrc | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/.bashrc b/.bashrc index 6182589..e255681 100644 --- a/.bashrc +++ b/.bashrc @@ -1,6 +1,11 @@ # If not running interactively, don't do anything more [ -z "$PS1" ] && return +# Download .git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh +# Download .fonts/dejavu/DejaVuSansMonoNerdFontCompleteMono.ttf https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20Nerd%20Font%20Complete%20Mono.ttf +# Download .compile-python.sh https://git.afpy.org/mdk/compile-python/raw/branch/main/compile-python.sh +# Download .python-prompt.sh https://git.afpy.org/mdk/python-prompt/raw/branch/main/python-prompt.sh + DEBEMAIL=julien DEBEMAIL=$DEBEMAIL@ DEBEMAIL=${DEBEMAIL}palard.fr @@ -46,25 +51,18 @@ alias ls='ls --color=auto' alias fingerprint='find /etc/ssh -name "*.pub" -exec ssh-keygen -l -f {} \;' alias rekey='ssh-add -e /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so >/dev/null 2>&1; ssh-add -s /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so' - -if ! [[ -f "$HOME/.git-prompt.sh" ]] -then - wget -q -O "$HOME/.git-prompt.sh" https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -fi - -if ! [[ -f "$HOME/.fonts/dejavu/DejaVuSansMonoNerdFontCompleteMono.ttf" ]] -then - mkdir -p ~/.fonts/dejavu/ - wget -qO "$HOME/.fonts/dejavu/DejaVuSansMonoNerdFontCompleteMono.ttf" "https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DejaVuSansMono/Regular/complete/DejaVu%20Sans%20Mono%20Nerd%20Font%20Complete%20Mono.ttf" -fi - -for extra in /etc/bash_completion ~/.git-prompt.sh ~/clones/mdk/compile-python/compile-python.sh ~/clones/mdk/python-prompt/python-prompt.sh +grep '^# Download ' $HOME/.bashrc | while read -r _ _ dest src do - if [[ -f "$extra" ]] - then - . $extra - fi + if [[ (! -f "$HOME/$dest") || $(( RANDOM % 100 )) == 0 ]] + then + wget -q -O "$HOME/$dest" "$src" + fi + if [[ "$dest" == *".sh" ]] + then + . "$dest" + fi done +unset dest src if [[ "$TERM" != 'dumb' ]] then