Files
42header/set_header.sh

39 lines
716 B
Bash
Raw Permalink Normal View History

#!/bin/bash
# ./set_header.sh
2021-10-29 09:05:15 +02:00
set -e
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/
2021-10-29 09:05:15 +02:00
# Set variables
if test -f ~/.zshrc
then
2021-10-29 09:05:15 +02:00
if ! grep -q ' USER=' ~/.zshrc && [ -z "$USER" ]
2021-10-29 08:30:44 +02:00
then
echo 'export USER=`whoami`' >> ~/.zshrc
fi
2021-10-29 09:05:15 +02:00
if ! grep -q ' MAIL=' ~/.zshrc
2021-10-29 08:30:44 +02:00
then
2021-10-29 09:05:15 +02:00
echo "export MAIL=\"${MAIL}\"" >> ~/.zshrc
2021-10-29 08:30:44 +02:00
fi
2021-10-29 09:05:15 +02:00
source ~/.zshrc
fi
2021-10-29 09:05:15 +02:00
if test -f ~/.bashrc
then
2021-10-29 09:05:15 +02:00
if ! grep -q ' USER=' ~/.bashrc && [ -z "$USER" ]
2021-10-29 08:30:44 +02:00
then
echo 'export USER=`whoami`' >> ~/.bashrc
fi
2021-10-29 09:05:15 +02:00
if ! grep -q ' MAIL=' ~/.bashrc
2021-10-29 08:30:44 +02:00
then
2021-10-29 09:05:15 +02:00
echo "export MAIL=\"${MAIL}\"" >> ~/.bashrc
2021-10-29 08:30:44 +02:00
fi
2021-10-29 09:05:15 +02:00
source ~/.bashrc
fi