Is there any way to set +x
bit on script while creating?
For example I run:
vim -some_option_to_make_file_executable script.sh
and after saving I can run file without any additional movings.
ps. I can run chmod
from vim
or even from console itself, but this is a little annoying, cause vim
suggests to reload file. Also it's annoying to type chmod
command every time.
pps. It would be great to make it depending on file extension (I don't need executable .txt
:-) )
if
's into oneif getline(1) =~ "^#!/bin/"
. Anyway that's amazing. Thank you. – rush Jun 04 '12 at 13:39au BufWritePost * if getline(1) =~ "^#!" | silent !chmod +x % | endif
– vault Feb 17 '16 at 14:39/bin
doesn't immediately follow the shebang, like#!/usr/bin/env
. A way around that is of course to use a wildcard:getline(1) =~ "^#!.*/bin/"
. – Harald Nordgren Apr 02 '16 at 14:47written/bin/bash: endif: command not found /bin/bash: endif: command not found
– StevieD Feb 10 '17 at 21:36au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent execute "!chmod a+x <afile>" | endif | endif
– StevieD Feb 10 '17 at 21:44