Skip to content

Make script files executable automatically

by mickey on January 19th, 2011

You can force Emacs to make a file executable (respecting your umask settings) if Emacs considers it a script. To determine if it is a script, Emacs will look for the hash-bang notation in the file and treat it as a script if it finds it.

Add this to your .emacs and Emacs will then make the file executable if it is a script.

5 Comments
  1. tom permalink

    I was just wondering how to do this the other day, thought it would take a much more complicated solution.
    Thanks for the great tip.

  2. U Avalos permalink

    That’s why I love emacs.

    Gotta spend time to learn how to code in lisp though. Everyday I’m tempted more and more…

    • mickey permalink

      You should learn it! Elisp is a fun little language and a very practical way to learn a Lisp-like and put it to good use.

  3. Nice tip.

    By the way, in case anyone else runs into this, here’s something that confused me: I’m using the emacs-starter-kit, and I put this into my init file but I just evaled it with C-x C-e instead of restarting. I was confused about why it didn’t work, but it turns out that there’s something in starter-kit-lisp.el that sets after-save-hook to buffer local in order to add a hook that removes .elc files when you save a .el file. When I actually restarted it worked.

Trackbacks & Pingbacks

  1. Tweets that mention Make script files executable automatically | Mastering Emacs -- Topsy.com

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS