From f4e30804323cfa054467bc319f0b4ba71356e343 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 20 Jun 2017 16:18:27 +0200 Subject: [PATCH] lang/sh: improve zsh buffer detection --- modules/lang/sh/config.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/lang/sh/config.el b/modules/lang/sh/config.el index 167adc7b7..2f4c9a23d 100644 --- a/modules/lang/sh/config.el +++ b/modules/lang/sh/config.el @@ -35,7 +35,11 @@ ;; sh-mode has file extensions checks for other shells, but not zsh, so... (defun +sh|detect-zsh () - (when (and buffer-file-name (string-match-p "\\.zsh\\'" buffer-file-name)) + (when (or (and buffer-file-name + (string-match-p "\\.zsh\\'" buffer-file-name)) + (save-excursion + (goto-char (point-min)) + (looking-at-p "^#!.+zsh[$\\s-]"))) (sh-set-shell "zsh"))) (add-hook 'sh-mode-hook #'+sh|detect-zsh))