Declaraive is more maintainable than imperative.

This commit is contained in:
Julien Palard 2023-12-22 19:07:36 +01:00
parent c519521834
commit c68eb59d99
Signed by: mdk
GPG Key ID: 0EFC1AC1006886F8
1 changed files with 15 additions and 17 deletions

32
.bashrc
View File

@ -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