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) |
5 Comments
→
Mastering Emacs
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.
That’s why I love emacs.
Gotta spend time to learn how to code in lisp though. Everyday I’m tempted more and more…
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.
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.