Make Shell Scripts Executable By Default

If you use vim to write shell scripts, you might want to save the “chmod +x” command after saving the script.

By adding the following line to your vimrc file (typically, it’s located at ~/.vimrc), scripts will automatically become executable.

au BufWritePost * if getline(1) =~ “^#!” | if getline(1) =~ “/bin/” | silent !chmod a+x <afile> | endif | endif

(meaning, if the file includes #! with “/bin/” in the path, apply “chmod a+x” on this file).

via shell-fu.

Have fun ;)

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Related posts:

  1. Re-Use A Bash Command With Different Parameters
  2. Fetch Links From Twitter Into Your RSS Reader
  3. Google Reader Useful “Send To” Services
  4. Strip the File Name Suffix off a Bash Variable

Tags: , , ,

Saturday, September 26th, 2009 Vim

Leave a Reply

my email
my photo
Hi,
My name is Amir Watad. I have a BSc. in biomedical engineering from The Biomedical Engineering school , Technion , Israel, and a BSc. in electrical engineering from The Electrical Engineering school , Technion , Israel.
I'm a Verification Engineer in Mellanox Technologies Ltd.
I love Linux, the Command Line and the OpenSource Community.
I used to write Poems (Arabic) when I was able to find time for this.
September 2009
S M T W T F S
« Jul   Dec »
 12345
6789101112
13141516171819
20212223242526
27282930  
SEO Powered by Platinum SEO from Techblissonline

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.