Fix set_header.sh
This commit is contained in:
@@ -26,9 +26,7 @@ vim Makefile
|
|||||||
Below replace "marvin" with your 42 Network login.
|
Below replace "marvin" with your 42 Network login.
|
||||||
|
|
||||||
```
|
```
|
||||||
export USER="marvin"
|
USER="marvin" ./set_header.sh
|
||||||
|
|
||||||
./set_header.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
In all your git repositories:
|
In all your git repositories:
|
||||||
@@ -60,7 +58,6 @@ git config user.email "marvin@student.42lausanne.ch"
|
|||||||
UNIX/BSD Distro (MacOS X, FreeBSD, OpenBSD, etc.) edit `~/.zshrc`:
|
UNIX/BSD Distro (MacOS X, FreeBSD, OpenBSD, etc.) edit `~/.zshrc`:
|
||||||
```
|
```
|
||||||
vim ~/.zshrc
|
vim ~/.zshrc
|
||||||
export USER="marvin"
|
|
||||||
export MAIL="marvin@student.42lausanne.ch"
|
export MAIL="marvin@student.42lausanne.ch"
|
||||||
<ESC> :wq
|
<ESC> :wq
|
||||||
source ~/.zshrc
|
source ~/.zshrc
|
||||||
@@ -69,7 +66,6 @@ source ~/.zshrc
|
|||||||
Linux/GNU Distro (Debian/Ubuntu, RedHat/SuSE, Arch, Gentoo, etc.) edit `~/.bashrc`:
|
Linux/GNU Distro (Debian/Ubuntu, RedHat/SuSE, Arch, Gentoo, etc.) edit `~/.bashrc`:
|
||||||
```
|
```
|
||||||
vim ~/.bashrc
|
vim ~/.bashrc
|
||||||
export USER="marvin"
|
|
||||||
export MAIL="marvin@student.42lausanne.ch"
|
export MAIL="marvin@student.42lausanne.ch"
|
||||||
<ESC> :wq
|
<ESC> :wq
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
@@ -85,8 +81,8 @@ source ~/.bashrc
|
|||||||
Troubleshooting:
|
Troubleshooting:
|
||||||
```
|
```
|
||||||
git config user.name
|
git config user.name
|
||||||
git config user.email
|
|
||||||
echo $USER
|
echo $USER
|
||||||
|
git config user.email
|
||||||
echo $MAIL
|
echo $MAIL
|
||||||
grep -e ' USER=' -e ' MAIL=' ~/.zshrc
|
grep -e ' USER=' -e ' MAIL=' ~/.zshrc
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,34 +1,38 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ./set_header.sh
|
# ./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
|
then
|
||||||
if ! grep -q ' USER=' "~/.zshrc" ] && [ -z "$USER" ]
|
if ! grep -q ' USER=' ~/.zshrc && [ -z "$USER" ]
|
||||||
then
|
then
|
||||||
echo 'export USER=`whoami`' >> ~/.zshrc
|
echo 'export USER=`whoami`' >> ~/.zshrc
|
||||||
fi
|
fi
|
||||||
if ! grep -q ' MAIL=' "~/.zshrc" ]
|
if ! grep -q ' MAIL=' ~/.zshrc
|
||||||
then
|
then
|
||||||
echo 'export MAIL="${USER}@student.42lausanne.ch"' >> ~/.zshrc
|
echo "export MAIL=\"${MAIL}\"" >> ~/.zshrc
|
||||||
fi
|
fi
|
||||||
|
source ~/.zshrc
|
||||||
fi
|
fi
|
||||||
if [ -f "~/.bashrc" ]
|
if test -f ~/.bashrc
|
||||||
then
|
then
|
||||||
if ! grep -q ' USER=' "~/.bashrc" ] && [ -z "$USER" ]
|
if ! grep -q ' USER=' ~/.bashrc && [ -z "$USER" ]
|
||||||
then
|
then
|
||||||
echo 'export USER=`whoami`' >> ~/.bashrc
|
echo 'export USER=`whoami`' >> ~/.bashrc
|
||||||
fi
|
fi
|
||||||
if ! grep -q ' MAIL=' "~/.bashrc" ]
|
if ! grep -q ' MAIL=' ~/.bashrc
|
||||||
then
|
then
|
||||||
echo 'export MAIL="${USER}@student.42lausanne.ch"' >> ~/.bashrc
|
echo "export MAIL=\"${MAIL}\"" >> ~/.bashrc
|
||||||
fi
|
fi
|
||||||
|
source ~/.bashrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
|
|
||||||
|
|
||||||
# Add stdheader to vim plugins
|
|
||||||
cp vim/stdheader.vim ~/.vim/plugin/
|
|
||||||
|
|
||||||
source ~/.zshrc
|
|
||||||
|
|||||||
Reference in New Issue
Block a user