Automatically making scripts executable
I just found a tip for emacs by Stephan Arentz
I found the feature really helpful. so here the vim
version:
function! MakeExecutable()
if (strpart(getline(1), 0, 2) == '#!')
silent !chmod +x %
endif
endfunction
autocmd bufwritepost * call MakeExecutable()
It does exactly the same things (ie check if the first line start with "#!")
And in bonus:
nnoremap <silent> <Leader>w :r !echo "\#\! `which <cword>`"<CR>kdd
this mapping calls which
to create a shebang. for example type python
(or perl, tcl, ruby, ...) and on the word press <Leader> w
it will replace the word with the correct shebang.
Written by gahtune
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#