Questions tagged [shell-mode]

is for the major mode for shell buffers. Use `C-c` prefix for accessing `M-x commands`.

Shell buffers run in , which is derived from comint-mode that runs subshells for , a command interpreter, in a .

and character mode are two input modes Emacs provides for running a .

Useful Links:

84 questions
17
votes
1 answer

How does emacs `shell-mode` know to prompt for sudo?

In shell-mode, a command like sudo CMD opens up a prompt in the echo area saying: [sudo] password for root: How does it know to do this? AFAIK, this behaviour cannot rise out of simply running sudo as usual, because the read builtin does not…
extremeaxe5
  • 639
  • 3
  • 10
16
votes
3 answers

Set indentation for shell script function

I am trying to set the number of spaces per indent for starting a new function in sh-mode (bash sub-mode). I have tried setting: '(sh-basic-offset 2) '(sh-indentation 2) '(smie-indent-basic 2) (as shown in custom-set-variables in .emacs) and some…
Robin Green
  • 949
  • 7
  • 16
14
votes
1 answer

How to prevent backspace from deleting my shell prompt?

It is a usual shell display: ME@mycomputer: ~$ echo When I do backspace several times It becomes: ME@mycompu How to prevent the system word from deleting
tom
  • 365
  • 1
  • 7
12
votes
1 answer

Automatically update default-directory when PWD changes in shell-mode and term-mode

Are there any options or packages which cause default-directory to be updated if the working directory changes in shell-mode and term-mode? I.e. when using cd, but the solution would have to be more robust than just look for this particular command…
tarsius
  • 25,298
  • 4
  • 69
  • 109
9
votes
2 answers

How to run a previous unique command in an Emacs shell (without repeats)?

In Emacs shell, is there a command similar to M-p but which would skip repeated commands? That is, it would go to the next different command. Similar to regular Linux terminal. So if I were to run: ls ./script ./script ./script make and press M-p…
Anton
  • 163
  • 9
8
votes
1 answer

How to turn off alignment-indent after line continuation in Shell-script mode?

In Shell-script[sh] mode, Emacs defaults to this style of indentation: /this/is/an/example/command/broken/over_multiple_lines which \ causes \ …
Malvineous
  • 265
  • 1
  • 8
7
votes
3 answers

Emacs: How to clear a subshell screen?

In Emacs interactive subshell, when I type clear, the screen is not cleared as it should do in a normal Ubuntu Terminal, for example. When I press Ctrl + l(twice if the screen is full), the screen gets cleared; but as soon as I type any command, let…
Billal Begueradj
  • 345
  • 1
  • 5
  • 18
7
votes
2 answers

Any way to have emacs shell pass the TAB into a readline command running inside it?

Eg. when you're running nice things like Perl or Ruby REPLs, you have code/command completion exposed via GNU Readline. What I want to do is set some elisp/env variable when entering/exiting such a program to indicate that I want shell-mode to pass…
Mark
  • 1,409
  • 1
  • 15
  • 20
7
votes
1 answer

How can I change which shell script mode I'm in?

Occasionally, emacs opens a file in shell-script[fish] when I want it to open in shell-script[bash]. How can I manually change the subtype of shell-script mode that I'm in?
Dan
  • 275
  • 2
  • 8
6
votes
1 answer

How to automatically kill a shell buffer when the shell process exits

In shell-mode when you exit the shell process (e.g. by typing exit) the buffer still hangs around (with the message "Process shell<1> finished"). How can I automatically kill the shell buffer when the shell process exits? (1) Is there a package…
halloleo
  • 1,215
  • 9
  • 23
6
votes
1 answer

Equivalent of pausing (CTRL-Z bindkey) in shell-mode

Let's say that I run a process in the foreground, I then wish to pause it, and maybe assign it to the background. In normal C-shell, it is very easily done. I just press C-z, and then I input the command bg &. How can I achieve the same in emacs…
user1134991
  • 289
  • 1
  • 9
6
votes
2 answers

weird characters in shell mode with zsh

I recently switched to zsh (with oh-my-zsh) as my primary shell, but running the shell from emacs results in some strange (for lack of a better word) "residural" characters; however changing to bash removes these characters: ➜ ~ ^[[?2004h bash …
Electric Coffee
  • 163
  • 1
  • 5
5
votes
2 answers

Symbol's value as variable is void: shell-mode-map

Windows 10, Emacs 25.1 In my init.el (define-key shell-mode-map (kbd "C-c C-l") 'helm-comint-input-ring) But when I start emacs I get error: Symbol's value as variable is void: shell-mode-map
user8542613
  • 643
  • 6
  • 16
5
votes
2 answers

How can I make ANSI color codes inside the prompt show up in shell-mode?

I have shell-mode set up to work with ANSI colors. In older versions of Emacs, this extended to the prompt but now it doesn't and the prompt remains uncolored. PS1 is set with ANSI color codes which work when it's printed out but don't work in the…
Tikhon Jelvis
  • 6,152
  • 2
  • 27
  • 40
1
2 3 4 5 6