Improve set_header.sh and doc
This commit is contained in:
@@ -27,7 +27,6 @@ Below replace "marvin" with your 42 Network login.
|
|||||||
|
|
||||||
```
|
```
|
||||||
export USER="marvin"
|
export USER="marvin"
|
||||||
export MAIL="marvin@student.42lausanne.ch"
|
|
||||||
|
|
||||||
./set_header.sh
|
./set_header.sh
|
||||||
```
|
```
|
||||||
@@ -73,14 +72,15 @@ vim ~/.bashrc
|
|||||||
export USER="marvin"
|
export USER="marvin"
|
||||||
export MAIL="marvin@student.42lausanne.ch"
|
export MAIL="marvin@student.42lausanne.ch"
|
||||||
<ESC> :wq
|
<ESC> :wq
|
||||||
. ~/.bashrc
|
source ~/.bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
### **Note**
|
### **Note**
|
||||||
|
|
||||||
- Your git username and email will always have the priority over $USER and $MAIL variables.
|
- Your git username and email will always have the priority over $USER and $MAIL variables.
|
||||||
- if you are outside a git repo tree, it will use the $USER and $MAIL environement variables.
|
- If you are outside a git repo tree, it will use the $USER and $MAIL environement variables.
|
||||||
- if none of the above, it will default to marvin@student.42lausanne.ch and marvin as username.
|
- I none of the above, it will default to marvin@student.42lausanne.ch and marvin as username.
|
||||||
|
- Usually you don't want to overwrite $USER as is the logged user and is already defined.
|
||||||
|
|
||||||
Troubleshooting:
|
Troubleshooting:
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,14 +3,27 @@
|
|||||||
|
|
||||||
# Set variables
|
# Set variables
|
||||||
|
|
||||||
if [ ! -z "$USER" ]
|
if [ -f "~/.zshrc" ]
|
||||||
then
|
then
|
||||||
|
if ! grep -q ' USER=' "~/.zshrc" ] && [ -z "$USER" ]
|
||||||
|
then
|
||||||
echo 'export USER=`whoami`' >> ~/.zshrc
|
echo 'export USER=`whoami`' >> ~/.zshrc
|
||||||
fi
|
fi
|
||||||
|
if ! grep -q ' MAIL=' "~/.zshrc" ]
|
||||||
if [ ! -z "$MAIL" ]
|
then
|
||||||
then
|
|
||||||
echo 'export MAIL="${USER}@student.42lausanne.ch"' >> ~/.zshrc
|
echo 'export MAIL="${USER}@student.42lausanne.ch"' >> ~/.zshrc
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f "~/.bashrc" ]
|
||||||
|
then
|
||||||
|
if ! grep -q ' USER=' "~/.bashrc" ] && [ -z "$USER" ]
|
||||||
|
then
|
||||||
|
echo 'export USER=`whoami`' >> ~/.bashrc
|
||||||
|
fi
|
||||||
|
if ! grep -q ' MAIL=' "~/.bashrc" ]
|
||||||
|
then
|
||||||
|
echo 'export MAIL="${USER}@student.42lausanne.ch"' >> ~/.bashrc
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
|
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
|
||||||
|
|||||||
Reference in New Issue
Block a user