aboutsummaryrefslogtreecommitdiff
path: root/plugin/shebang_create_exec.vim
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/shebang_create_exec.vim')
-rw-r--r--plugin/shebang_create_exec.vim21
1 files changed, 21 insertions, 0 deletions
diff --git a/plugin/shebang_create_exec.vim b/plugin/shebang_create_exec.vim
new file mode 100644
index 0000000..401a23b
--- /dev/null
+++ b/plugin/shebang_create_exec.vim
@@ -0,0 +1,21 @@
+"
+" shebang_create_exec.vim: Make a file executable on first save if it starts with a
+" shebang.
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" License: Same as Vim itself
+"
+if exists('g:loaded_shebang_create_exec') || &compatible
+ finish
+endif
+if !has('autocmd') || !has('unix') || !exists('*shellescape')
+ finish
+endif
+let g:loaded_shebang_create_exec = 1
+
+" Set up hook for before writes to check the buffer for new shebangs
+augroup shebang_create_exec
+ autocmd!
+ autocmd BufWritePre *
+ \ call shebang_create_exec#Check(expand('<afile>:p'))
+augroup END