Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

 
discard

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.