📜 ⬆️ ⬇️

Making Script Files Executable

On duty, you often need to write shell scripts to automate routine tasks. After saving the file, you must give it the right to execute it each time. Such a task can also be automated directly by means of the editor.

Open / create file ~ /. vimrc and add the following line to it:
au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent !chmod a+x | endif | endif
The given directive checks the first line of the saved file and, if it starts with "#!" and contains "/ bin /", assigns the last executable attribute.

Source: shell-fu .

')

Source: https://habr.com/ru/post/63904/


All Articles