Questions tagged [sh-mode]

Major mode for editing shell scripts.

This mode works for many shells, since they all have roughly the same syntax, as far as commands, arguments, variables, pipes, comments etc. are concerned. Unless the file's magic number indicates the shell, your usual shell is assumed. Since filenames rarely give a clue, they are not further analyzed.

9 questions
4
votes
0 answers

Highlight variables without $ inside (( )) when in sh-mode?

Is there a way to modify sh-mode to highlight variables inside a double parentheses construct when not using the dollar sign prefix? For example I want the i to be highlighted in ((i++)) without the need of writing $i.
3
votes
1 answer

sh-mode: Scan error: "Containing expression ends prematurely",

Generate a file with this: (echo '#!/bin/bash' echo 'myfunc() {' echo "cat <<'z'" seq 135 echo zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz echo z echo '}') >out Open it in Emacs. When pressing C-M-f I get the error: Scan error: "Containing…
Ole Tange
  • 143
  • 4
2
votes
2 answers

Can emacs handle bash extglob case patterns properly?

This question is in two parts: How to cause emacs linter to recognize an extglob expression as an ability instead of a syntax error? How to cause emacs indenter to recognize an extglob expression as a complete entry? I have hacked and uploaded the…
Paul
  • 183
  • 8
2
votes
1 answer

How to automatically select *interpretation* buffer window

When I am writing a shell script in sh-mode and decide to run it, I hit C-cC-x (executable-interpret). An *interpretation* buffer is displayed, showing the script's output. Is there a robust way to automatically make this *interpretation* buffer…
John Goofy
  • 121
  • 2
2
votes
1 answer

zsh expansion modifiers are treated as comments

zsh has a ton of syntax. In particular, the # character serves a bunch of different roles. Here are two that are problematic: Prefix globbing flags (#b)(*).c This finds all files that end in .c and captures their basenames using backreferences…
PythonNut
  • 10,243
  • 2
  • 29
  • 75
1
vote
1 answer

How to make a file variable buffer local?

I have customized the variable sh-indentation with 4, but in one file I would like to use a different value. So I defined a file variable: # -*- mode: sh; sh-indentation: 2; -*- But the result is not what I have expected. When I open the file the…
ceving
  • 1,308
  • 1
  • 14
  • 28
0
votes
0 answers

How to make curly braces auto indent in sh-mode

If typed in sh-mode the closing brace is not auto-indented: function() { } If typed in c-mode the closing brace is auto-indented when inserted: function() { } The exact keystrokes are: f u n c t i o n ( ) ENT { ENT }. How can I change this…
young_souvlaki
  • 526
  • 2
  • 13
0
votes
1 answer

How to set key binding to `C-c C-t` in `sh-mode`?

By default C-c C-t has sh-tmp-file binding in sh-mode, which I want to change.: C-c C-t runs the command sh-tmp-file (found in sh-mode-map), which is an interactive compiled Lisp function in ‘sh-script.el’. It is bound to C-c C-t. I have tried to…
alper
  • 1,238
  • 11
  • 30
0
votes
2 answers

How do I change the default shell for `sh-mode`?

sh-mode usually does a great job of auto-magically detecting which shell a file is intended to be run by. It looks at the shebang, for instance. However, I have a bunch of files that are intended to be sourced, not run as executables, and thus I…