Making scripts executable with vim hooks
I write a lot of shell, python and sometimes perl scripts to get things done and it gets somewhat mildly annoying to set them as executable every once in a while. Here’s a trick from shell-fu Tip #858
I just added the following line to my ~/.vimrc
au BufWritePost * if getline(1) =~ “^#!” | if getline(1) =~ “/bin/” | if getline(1) =~ “/usr/bin” | silent !chmod a+x <afile> | endif | endif
I have improved the script a little bit as I need to use python a lot (i.e, #!/usr/bin/env python)
If you have a better way to write the regex, comment here but I think this is good enough for most purposes.













People get clever with regex, start implementing stuffs.. and they figure they have two problems now; Regex and the problem itself