Files
42header/README.md

149 lines
3.7 KiB
Markdown
Raw Normal View History

# **42 Header**
42Lausanne (Switzerland)
### **Description**
42 standard header for vim editor.
![42 header](img/42header.png)
2021-10-28 16:32:16 +02:00
### **Usage**
2021-10-28 16:38:07 +02:00
In **NORMAL** mode (<kbd>ESC</kbd>) you can simply press the shortcut <kbd>F2</kbd> (or <kbd>FN</kbd> <kbd>F2</kbd>) or use `:FT` as command.
2021-10-28 16:32:16 +02:00
```
vim 42.c
<ESC> <F2>
<ESC> :wq
2021-10-28 16:32:16 +02:00
vim Makefile
<ESC> :FT
<ESC> :wq
```
2021-10-28 16:32:16 +02:00
### **Quick Setup**
Below replace "marvin" with your 42 Network login.
```
2021-10-29 09:05:15 +02:00
USER="marvin" ./set_header.sh
2021-10-28 16:32:16 +02:00
```
2021-11-05 14:14:37 +01:00
If you want to setup the same email and username for all your git:
```
git config --global user.name marvin
git config --global user.email marvin@student.42lausanne.ch
2021-11-05 14:14:37 +01:00
```
Otherwise setup it on a case-by-case basic:
2021-10-28 16:32:16 +02:00
```
git clone git@... project
cd project
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`
2021-10-28 16:32:16 +02:00
### **Manual Setup**
Below replace "marvin" with your 42 Network login.
Copy `stdheader.vim` in your `~/.vim/plugin`.
```
test -d ~/.vim/plugin || mkdir -p ~/.vim/plugin
cp -va vim/stdheader.vim ~/.vim/plugin
```
2021-11-05 14:14:37 +01:00
If you want to setup the same email and username for all your git:
```
git config --global user.name marvin
git config --global user.email marvin@student.42lausanne.ch
2021-11-05 14:14:37 +01:00
```
Otherwise setup it on a case-by-case basic:
2021-10-28 16:32:16 +02:00
```
git clone git@... project
cd project
git config user.name "marvin"
git config user.email "marvin@student.42lausanne.ch"
```
2021-10-28 17:04:06 +02:00
UNIX/BSD Distro (MacOS X, FreeBSD, OpenBSD, etc.) edit `~/.zshrc`:
2021-10-28 16:32:16 +02:00
```
vim ~/.zshrc
export MAIL="marvin@student.42lausanne.ch"
<ESC> :wq
source ~/.zshrc
```
2021-10-28 17:04:06 +02:00
Linux/GNU Distro (Debian/Ubuntu, RedHat/SuSE, Arch, Gentoo, etc.) edit `~/.bashrc`:
2021-10-28 16:32:16 +02:00
```
vim ~/.bashrc
export MAIL="marvin@student.42lausanne.ch"
<ESC> :wq
2021-10-29 08:30:44 +02:00
source ~/.bashrc
2021-10-28 16:32:16 +02:00
```
### **Note**
2021-10-28 16:44:32 +02:00
- Your git username and email will always have the priority over $USER and $MAIL variables.
2021-10-29 08:30:44 +02:00
- 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.
2021-10-29 08:30:44 +02:00
- Usually you don't want to overwrite $USER as is the logged user and is already defined.
2021-10-28 16:44:32 +02:00
Troubleshooting:
```
git config user.name
echo $USER
2021-10-29 09:05:15 +02:00
git config user.email
2021-10-28 16:44:32 +02:00
echo $MAIL
2021-10-29 09:05:15 +02:00
grep -e ' USER=' -e ' MAIL=' ~/.zshrc
2021-10-28 16:44:32 +02:00
```
2021-10-28 16:32:16 +02:00
The location of this alternative version of stdheader.vim:
- ~/.vim/plugin/stdheader.vim
- $HOME/.vim/plugin/stdheader.vim
2021-10-28 16:32:16 +02:00
The location of the official stdheader.vim in 42lausanne's clusters:
- /usr/share/vim/vim80/plugin/stdheader.vim
2021-10-28 16:32:16 +02:00
- /usr/share/vim/vim81/plugin/stdheader.vim (at the time of writing)
- /usr/share/vim/vim82/plugin/stdheader.vim
### **Credits**
2021-10-28 16:32:16 +02:00
- [@42Paris](https://github.com/42Paris)
- [@zazard](https://github.com/zazard)
- [@xbeheydt](https://github.com/xbeheydt)
2021-10-28 17:04:06 +02:00
### **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/
```
2021-10-28 17:04:06 +02:00
- 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
test -d ~/.vim/autoload || mkdir -p ~/.vim/autoload
git clone https://github.com/vim-airline/vim-airline.git vim-airline
cd vim-airline
cp -va autoload/* ~/.vim/autoload/
cp -va plugin/* ~/.vim/plugin/
```
[RTFM](https://github.com/vim-airline/vim-airline/blob/master/doc/airline.txt)
### **License**
This work is published under the terms of **[42 Unlicense](https://github.com/gcamerli/42unlicense)**.