Fix set_header.sh

This commit is contained in:
gbaconni
2021-10-29 09:05:15 +02:00
parent 59d02ff201
commit 0bffe673f8
2 changed files with 22 additions and 22 deletions

View File

@@ -1,34 +1,38 @@
#!/bin/bash
# ./set_header.sh
# Set variables
set -e
if [ -f "~/.zshrc" ]
DOMAIN=$DOMAIN-student.42lausanne.ch}
MAIL=${MAIL-${USER}@${DOMAIN}}
# Add stdheader to vim plugins
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
cp vim/stdheader.vim ~/.vim/plugin/
# Set variables
if test -f ~/.zshrc
then
if ! grep -q ' USER=' "~/.zshrc" ] && [ -z "$USER" ]
if ! grep -q ' USER=' ~/.zshrc && [ -z "$USER" ]
then
echo 'export USER=`whoami`' >> ~/.zshrc
fi
if ! grep -q ' MAIL=' "~/.zshrc" ]
if ! grep -q ' MAIL=' ~/.zshrc
then
echo 'export MAIL="${USER}@student.42lausanne.ch"' >> ~/.zshrc
echo "export MAIL=\"${MAIL}\"" >> ~/.zshrc
fi
source ~/.zshrc
fi
if [ -f "~/.bashrc" ]
if test -f ~/.bashrc
then
if ! grep -q ' USER=' "~/.bashrc" ] && [ -z "$USER" ]
if ! grep -q ' USER=' ~/.bashrc && [ -z "$USER" ]
then
echo 'export USER=`whoami`' >> ~/.bashrc
fi
if ! grep -q ' MAIL=' "~/.bashrc" ]
if ! grep -q ' MAIL=' ~/.bashrc
then
echo 'export MAIL="${USER}@student.42lausanne.ch"' >> ~/.bashrc
echo "export MAIL=\"${MAIL}\"" >> ~/.bashrc
fi
source ~/.bashrc
fi
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
# Add stdheader to vim plugins
cp vim/stdheader.vim ~/.vim/plugin/
source ~/.zshrc