使emacs将文件识别为bash

时间:2016-02-10 20:29:55

标签: bash emacs

我正在尝试让emacs认识到一个脚本(应该是源代码)是用bash编写的。我把

# this is a -*- bash -*- script

在第一行,但它仍在sh模式下打开。我可以通过将#!/usr/bin/env bash放在第一行来使其工作,但我不愿意这样做,因为它使脚本看起来像它的可执行文件,而我希望它来源。为什么emacs没有识别我的提示?

1 个答案:

答案 0 :(得分:1)

您可以使用以下内容:

# -*- mode: shell-script ; eval: (sh-set-shell "bash") -*-

但是Emacs会问你是否真的想要执行不安全的代码。