-
-
Save ralavay/c4c7750795ccfd72c2db to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# | |
# Highligh Nginx config file in Vim | |
# Download syntax highlight | |
mkdir -p ~/.vim/syntax/ | |
wget http://www.vim.org/scripts/download_script.php?src_id=19394 -O ~/.vim/syntax/nginx.vim | |
# Set location of Nginx config file | |
cat > ~/.vim/filetype.vim <<EOF | |
au BufRead,BufNewFile /etc/nginx/*,/etc/nginx/conf.d/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif | |
EOF |
Very very useful, thank you very much. Eye candy for my eyes
Quite useful, thank you.
an alternative to filetype.vim
file would be having sth like that at the end of nginx config file:
# vi: filetype=nginx
pros: you are not limited to have nginx config in /etc/nginx directory
cons: you need to add this modeline to the file
perfect ubuntu 18.04
๐ now i can see my typo's a bit earlier :-)
for users with vim-plug
cat << EOF > ~/.vim/ftdetect/nginx.vim
au BufRead,BufNewFile /etc/nginx/*,/etc/nginx/conf.d/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif
EOF
it's useful,thanks for that
not sure why its missing, but the standard nginx.conf is not in the filetypes list.
Why would i not use the coloring on any file called nginx.conf?
so i needed
au BufRead,BufNewFile nginx.conf,/etc/nginx/,/etc/nginx/conf.d/,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif
We use a lot of dockerized / containerized nginx's where the config is never in the standard locations
๐
thanks
๐๐๐ป
an alternative to
filetype.vim
file would be having sth like that at the end of nginx config file:
# vi: filetype=nginx
pros: you are not limited to have nginx config in /etc/nginx directory cons: you need to add this modeline to the file
Add curl -L to follow redirects.