The Mastering Emacs ebook cover art

Out now — Updated for Emacs 25

$39.99 Buy Now

Learn More

Make script files executable automatically

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.

(add-hook 'after-save-hook
  'executable-make-buffer-file-executable-if-script-p)