Search code examples
emacssyntax-highlightingstartup

Shell script mode automatically at each emacs start


Each time when I edit bash script I type a command M-x shell-script-mode. And then I get nice shell code higlighting. How to get it automatically each time I start emacs so I do not have to type the command. When I added (shell-script-mode) to init.el it did not help.


Solution

  • You can set the default major mode to be whatever you want by adding

    (setq-default major-mode 'shell-script-mode)
    

    to your init file. That will ensure that any newly created buffer will be in shell-script-mode unless its mode is specified otherwise (e.g. through auto-mode-alist). Whether it's a good idea or not, I don't know: I probably would not want that to be my default setting - but to each her/his own.