Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [shell-mode]

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

16
votes
1answer
1k views

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 ...
4
votes
1answer
74 views

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 ...
1
vote
1answer
26 views

Is there a way to restrict history in shell-mode?

I run lots of test in shell-mode because I love being able to search through the history. However, some of these tests print lots of info to stdout and will cause my memory usage to go through the ...
0
votes
2answers
35 views

Shell-mode execute script every time a shell is invoked

I have changed the emacs-shell mode shell to WSL ubuntu but however, the prompt is not very user-readable. For this reason I would like to execute a script that changes it so that its more readable ...
4
votes
3answers
278 views

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 ...
0
votes
1answer
142 views

emacs 25 shell-mode tab auto-completion issue with ksh

I have upgraded to Emacs 25.3 from 24. This issue only appears in the ksh. I've found that when I use bash then all is good. I find that in shell-mode when I hit tab to perform completion of the rest ...
0
votes
2answers
121 views

how to watch and cat and grep with emacs

This doesn't seem to work in M-x shell $ watch 'grep "FIX" /tmp/output | tail -n 5' I see Every 2.0s: grep "FIX" /tmp/output | tail -n 5 and I see My-hostname.local: Tue Aug 28 19:09:22 2018 on ...
1
vote
1answer
107 views

Shell mode: moving through the command history

In a shell in a terminal (Gnome Terminal + bash), the up and down keys allow me to browse through my command history. In shell-mode inside emacs, the up and down keys move around the buffer, which is ...
2
votes
1answer
36 views

Shell mode does not do autocompletion for loaded functions

When running in a terminal, the shell does auto-completion even for loaded functions: $ check-<tab><tab> check-bios-nx check-dirty check-language-support check-...
0
votes
0answers
38 views

No tty in shell buffers in Carbon Emacs on High Sierra

I've been using the Carbon Emacs port of Emacs, which is based on Emacs 22, for many years. I know it's way out of date and unmaintained, but I have a huge collection of home-grown extensions that I ...
0
votes
1answer
35 views

Shell buffer echoes partial long lines

I've written a command that ssh-es to a remote host and runs an interactive command there. Something like: (defun remote-command () (interactive) (pop-to-buffer (get-buffer-create "*remote-...
9
votes
2answers
135 views

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: ...
0
votes
1answer
228 views

from the spacemacs shell, how do I edit a file in a new buffer in the main window?

I open a new shell using space-'. From that shell window I can type ls to see files. Let's say I want to edit ~/.zshrc. From the shell prompt, what do I type to edit that file in a new buffer in the ...
1
vote
1answer
78 views

shell-mode: `C-a` moves point to beginning of line instead of after prompt

Usually C-a moves point to just after the prompt: andreas@my-computer:~/some/folder $ #here but occasionally something happens and C-a starts to the beginning of line: andreas@my-computer:~/some/...
1
vote
0answers
35 views

comint-input-ring-size ignored in shell-mode

I am trying to change comint-input-ring-size in shell mode in Emacs. The comint-input-file-name is correctly set to ~/.bash_history file which is a big file (around 5000 commands). However, if I set ...
0
votes
1answer
274 views

Shell IO Behavior For Emacs' Shells

The GNU page for Eshell says that Eshell is not a replacement for system shells such as bash or zsh. Use Eshell when you want to move text between Emacs and external processes; if you only want to ...
1
vote
1answer
90 views

How to write a helm function to select only from shell buffers

I recently switched from ido to helm. Now I'm using helm-buffers-list to select buffers. Additionally I want to create a customised helm-buffers-list function which allows me only to select from ...
0
votes
2answers
267 views

How to disable show-trailing-whitespace in emacs shell?

I have set show-trailing-whitespace as default in my .emacs file but I don't want it to work on shell and some specific buffer. I can disable it manually every time I open an emacs shell but I want ...
4
votes
1answer
87 views

EMACS shell mode that supports annotations

I often find myself doing things like installations or debugging where I would like to be able to work in shell mode but be able to insert annotations as I go. BBEdit has something like this but ...
3
votes
1answer
1k views

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
0
votes
1answer
64 views

Why does `M-x shell-mode` now always/usually open in a different window?

Since a relatively recent laptop re-install, whenever I M-x shell-mode (usually with the default shell buffer already running somewhere), the shell doesn't appear in the currently active window, ...
5
votes
1answer
521 views

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 ...
0
votes
0answers
118 views

Sending command from bash in shell-mode, and knowing buffer name

My specific goal is setting 'vc-mode from the $PROMPT1 snippet so that the mode line will show useful VC info in shell-mode. I can use emacsclient -e '(setq vc-mode "foo")' but that's not quite ...
1
vote
2answers
478 views

Get the same/map bindkeys in shell mode, in particular CTRL-r

I am using emacs s 23.1.1. I have started to really use in real-earnest the shell, in order to minimize the amounts of time I am out of emacs. However, the bind-keys are emacs based. Which is good, ...
0
votes
1answer
88 views

How to run `gprolog` under an Emacs sub-process shell?

I'd like to run the gprolog interactive interpreter in an Emacs sub-process shell (started with M-x shell). The interactive interpret starts without a problem, but it does not respond to some ...
0
votes
1answer
128 views

company-mode in shell-mode doesn't complete ./executables

With company-mode on in shell-mode, if I'm in ~/bin I can get completions if I type ~/bin/someprog or even ../bin/someprog but not ./someprog – is there some setting to fix this?
2
votes
1answer
313 views

How to send *shell* stdout directly to kill-ring?

Suppose that I have a *shell* buffer (i.e. a subordinate shell, started with M-x shell). Suppose also that at this shell's prompt, I can execute some command foo that sends some output to stdout. I ...
1
vote
2answers
2k views

differences of shell-mode vs. shell-script-mode?

What are the differences between shell-mode and shell-script-mode, or how/where would I read up the differences myself?
4
votes
1answer
551 views

Directory tracking in remote shell buffer

I use the shell command via C-u M-x shell to open a shell on a remote server by giving as default directory the path to the remote server (e.g /user@myserver.com:/home/user) (which should have the ...
4
votes
2answers
345 views

sh-script alignment issues

I'm sure emacs used to do it my way, but things appear to have changed (probably years ago, I've just been living with the pain). I want this (to conform to corp. standards): MULTIFORM=$( curl -...
2
votes
1answer
123 views

configure shell-mode to understand implicit cd

For the most part, I'm really liking shell-mode. I've configured it to read my .history file and if I spawn a dired or open a file it uses the current directory. I'm using tcsh with the set ...
4
votes
1answer
653 views

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 \ ...
1
vote
1answer
80 views

How to get shell mode to properly handle my PS1, which involves user-defined function calls?

My bash_profile includes a couple functions to build the prompt. This is a super-simplified version, which I'm using to try to debug the problem with: custom_git_function () { echo "git" } ...
10
votes
3answers
4k views

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 ...
2
votes
0answers
243 views

Custom Bash prompt doesn't display correctly in shell mode [closed]

In my .bashrc file I've set the PS1 variable to this to customize my prompt: export PS1='[\D{%Y-%d-%m} \t \u@\h \W]\n$ ' The format strings are explained in the Bash manual. This one gives me a ...
13
votes
1answer
464 views

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
2
votes
1answer
113 views

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 ...
3
votes
0answers
186 views

1024 char limit on command line in emacs shell mode on OSX

I am running into a 1024 character limit for a bash command line in emacs shell mode. For example the command: echo xxxxxxxxxxxxx...x with 1018 x's (for a total line length of 1023 chars) works ...
2
votes
1answer
167 views

How can i use a different shell in Emacs Shell?

I am currently using Zsh in my regular terminal app on my Mac OS X. However, it's heavily customized and colors don't appear properly inside Emacs. So I am thinking, I should probably use shell-mode ...
2
votes
1answer
1k views

How to run tmux in Aquamacs

I quite like tmux and Aquamacs. I've recently been interested in how to integrate the two together. As far as I know, one cannot run Aquamacs within a terminal even with the Aquamacs CLI tool, so the ...
6
votes
2answers
206 views

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 ...
1
vote
2answers
3k views

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 ...
5
votes
1answer
986 views

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?
4
votes
1answer
773 views

/bin/ls --color=always fails to produce colorized output in shell-mode

I have run M-x ansi-color-for-comint-mode-on. Also, when I use /bin/ls --color=always (or /bin/ls --color=auto) in a regular terminal, I do see colors in the output. It's only within Emacs' shell-...
3
votes
0answers
248 views

emacs shell: remove all non-printable characters

When I call gcalcli from the bash shell, I get the output described in the documentation. But when I run M-x shell on emacs (24.3) and call gcalcli from there, I get a lot of ^[ characters. Compare ...
5
votes
2answers
247 views

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 ...
1
vote
1answer
227 views

inserting passwords into pass from shell-mode

I'm trying to manage my passwords using the pass script from shell-mode inside Emacs. The script prompts me to enter the password twice as is customary when adding or changing passwords. The first ...
1
vote
2answers
219 views

What's a good workflow for having a few dedicated shell sessions?

At present I use a screen session in the terminal (outside of emacs), with window 0 devoted to running my web server, window 1 to running tests, and window 2 for general hacking. I like this flow and ...
1
vote
1answer
78 views

How to globally disable `shell-dirtrack-mode` after `(require 'shell)`

(require 'shell) enables shell-dirtrack-mode globally in every buffer. Is there a way to disable that behavior? The only workaround that I have found is to call (shell-dirtrack-mode -1) for each ...
1
vote
1answer
261 views

zsh EXTENDED_HISTORY corrupts shell-mode history

I use zsh with the EXTENDED_HISTORY option, which makes it so that in the shell history timestamps are stored which is useful for going back and diagnosing how you screwed up production. I'm trying to ...