aboutsummaryrefslogtreecommitdiff
path: root/vim/ftdetect/sh.vim
blob: dce776cf5467319b6af8c0e89334189cff941ce2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
" Add automatic commands to choose shell flavours based on filename pattern
augroup dfsh
  autocmd!

  " Names/paths of things that are Bash shell script
  autocmd BufNewFile,BufRead
      \ **/.dotfiles/bash/**,bash-fc-*
      \ let b:is_bash = 1 |
      \ setlocal filetype=sh

  " Names/paths of things that are Korn shell script
  autocmd BufNewFile,BufRead
      \ **/.dotfiles/ksh/**,.kshrc,*.ksh
      \ let b:is_kornshell = 1 |
      \ setlocal filetype=sh

  " Names/paths of things that are POSIX shell script
  autocmd BufNewFile,BufRead
      \ **/.dotfiles/sh/**,.shinit,.shrc,.xinitrc,/etc/default/*
      \ let b:is_posix = 1 |
      \ setlocal filetype=sh

  " If we determined something is b:is_kornshell, tack on b:is_ksh as well so
  " we can still tease out what is actually a kornshell script after sh.vim is
  " done changing our options for us; it conflates POSIX with Korn shell.
  autocmd BufNewFile,BufRead
      \ *
      \ if exists('b:is_kornshell') |
      \   let b:is_ksh = 1 |
      \ endif

augroup END