Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Emacs on a LINUX system that uses Portable Batch System (PBS) for controlling the use of resources. The PBS scripts require "#PBS -S /bin/..." as the first line in the script to declare the shell of the script to PBS. When I load the script into Emacs, there is no #!/bin/... to alert Emacs to which shell is being programmed. So, how can I get the shell-script-mode in Emacs to intepret #PBS -S /bin/bash to be a bash shell code?

share|improve this question

Add something like the following to the end of the file:

# Local Variables:
# mode: shell-script
# End: 

Of course, there are other ways, such as a distinct naming pattern used for setting the variable auto-mode-alist.

share|improve this answer

Add this to your .emacs:

(setq auto-mode-interpreter-regexp 
    "#\\(?:!\\|PBS -S \\)[ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)")

That makes Emacs consider #PBS -S as an alternative to the #! prefix.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.