Add user42 and mail42 support thanks to @xbeheydt

This commit is contained in:
gbaconni
2021-11-06 15:03:57 +01:00
parent ce5cfd31fd
commit c34768d62f
2 changed files with 27 additions and 6 deletions

View File

@@ -31,8 +31,8 @@ USER="marvin" ./set_header.sh
If you want to setup the same email and username for all your git:
```
git config --global user.name gbaconni
git config --global user.email gbaconni@student.42lausanne.ch
git config --global user.name marvin
git config --global user.email marvin@student.42lausanne.ch
```
Otherwise setup it on a case-by-case basic:
@@ -43,6 +43,14 @@ git config user.name "marvin"
git config user.email "marvin@student.42lausanne.ch"
```
For non git-based folder, set user and mail values directly in your vimrc
```vim
vim ~/.vimrc
let g:user42 = 'marvin'
let g:mail42 = 'marvin@student.42lausanne.ch'
```
<kbd>ESC</kbd> `:wq`
### **Manual Setup**
Below replace "marvin" with your 42 Network login.
@@ -55,8 +63,8 @@ cp -va vim/stdheader.vim ~/.vim/plugin
If you want to setup the same email and username for all your git:
```
git config --global user.name gbaconni
git config --global user.email gbaconni@student.42lausanne.ch
git config --global user.name marvin
git config --global user.email marvin@student.42lausanne.ch
```
Otherwise setup it on a case-by-case basic:
@@ -87,7 +95,7 @@ source ~/.bashrc
- 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.
- I none of the above, it will default to marvin@student.42lausanne.ch and marvin as username.
- If 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:
@@ -112,9 +120,18 @@ The location of the official stdheader.vim in 42lausanne's clusters:
- [@42Paris](https://github.com/42Paris)
- [@zazard](https://github.com/zazard)
- [@xbeheydt](https://github.com/xbeheydt)
### **Bonus**
- 42 Vim Headerguard [42-vim-headerguard](https://github.com/xbeheydt/42-vim-headerguard)
```
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
git clone https://github.com/xbeheydt/42-vim-headerguard.git 42-vim-headerguard
cd 42-vim-headerguard
cp -va plugin/* ~/.vim/plugin/
```
- Swissair is gone? Have a look to [Airline](https://github.com/vim-airline/vim-airline) for a nice status for vim.
```
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin

View File

@@ -6,7 +6,7 @@
" By: gbaconni@student.42lausanne.ch +#+ +:+ +#+ "
" +#+#+#+#+#+ +#+ "
" Created: 2013/06/15 12:45:56 by zaz #+# #+# "
" Updated: 2021/10/28 13:12:49 by gbaconni ### lausanne.ch "
" Updated: 2021/11/06 14:55:57 by gbaconni ### lausanne.ch "
" "
" **************************************************************************** "
@@ -64,6 +64,8 @@ function s:trimlogin ()
let l:login = systemlist('git config user.name')
if v:shell_error == 0 && len(l:login) > 0
let l:trimlogin = strpart(l:login[0], 0, 9)
elseif exists('g:user42')
let l:trimlogin = strpart(g:user42, 0, 9)
elseif exists("$USER")
let l:trimlogin = strpart($USER, 0, 9)
else
@@ -76,6 +78,8 @@ function s:trimemail ()
let l:email = systemlist('git config user.email')
if v:shell_error == 0 && len(l:email) > 0
let l:trimemail = strpart(l:email[0], 0, s:contentlen - 5)
elseif exists('g:mail42')
let l:trimemail = strpart(g:mail42, 0, s:contentlen - 5)
elseif exists("$MAIL")
let l:trimemail = strpart($MAIL, 0, s:contentlen - 5)
else