A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [shell]

Questions relating to commands for passing single command lines to shell sub-processes, running a shell interactively with input and output to an Emacs buffer, and for running a shell in a terminal emulator window.

Filter by
Sorted by
Tagged with
2
votes
1answer
56 views

How to check if emacs shell buffer busy or not?

If I start a long-running process in an emacs shell create by (shell), the shell will be busy for a while. How can I detect that programmatically (i.e., using elisp)? I tried: get the process by (...
2
votes
1answer
349 views

Prevent bash-completion adding an extra space when the word is incomplete

When using Emacs shell with the auto-completion feature enabled, I notice that whenever I perform typing and auto-completing a command, Emacs shell always adds an extra space after the first word. I ...
1
vote
1answer
414 views

Windows 10, Emacs 25.1, shell: Grep not work immediately

Windows 10 (64 bit), Emacs 25.1. I has Android application. And in console I start Android command "adb logcat" to show logs from Android device. But it's show many text. And I want to filter to show ...
2
votes
2answers
339 views

emacs opens shells in a random window, how to change this?

Try splitting the frame repeating some times the command C-x 3. Then try open the shell with M-x shell. It will open in a random window and not the one which you have typed the command from. Why?
3
votes
1answer
91 views

Saving raw ANSI escape codes in M-x shell, M-x eshell, or M-x term

Each of M-x shell, M-x eshell, and M-x term in Emacs lets me save the buffer to a text file. But the terminal colors are not saved. How do I save the raw ANSI escape sequences too?
0
votes
1answer
113 views

redirect stderr to a file in call-process-region

I have been reading the documentation for call-process-region here and I am trying to redirect stderr to a file. from the the documentation, this looks correct (call-process-region beg end perltidy-...
2
votes
0answers
99 views

Emacs shell and telnet buffer auto jumps to end of buffer while browsing buffer contents

Was recently required to update to RHEL 7.x and with that came a newer release of Emacs (24.3.1). With emacs I am a big user of shells and telnet sessions within emacs so that I can easily browse the ...
0
votes
1answer
546 views

C++ “std::cin >> ” is not pausing to read input from Emacs shell

The following program is from https://www.cs.bu.edu/teaching/tool/emacs/programming/ #include <iostream> int main() { int howmany; std::cout << "Enter a number: "; std::cin >&...
0
votes
2answers
136 views

How to troubleshoot and diagnose escaped-character display errors in Emacs shell?

I make much use of sub-shells within Emacs (initiated via M-x shell), and, because of this, I run into problems like the one illustrated1 below way too often: $ python -m pdb /tmp/hello_world.py [2] ...
2
votes
1answer
417 views

How to open system's command line at the directory of the current buffer?

Is there any easy way to open the system command line interface (e.g., cmd in Windows) at the directory containing the current buffer (if any)? Note that M-x shell open a command line interface within ...
1
vote
2answers
343 views

tramp and fish shell (local)

How to setup emacs tramp to open remote files while local shell is fish? More precisely is how to ask tramp to use bash shell instead of one named in SHELL environment variable?
0
votes
0answers
66 views

Retaining focus while displaying graphics windows

NB: The Emacs world uses the word frame to refer to what in most other contexts is called window, and uses the word window to describe something else. In this post, however, the word window always ...
1
vote
1answer
175 views

Cannot use find-dired: setq: Searching for program: is a directory,

The error is raised by shell-command--shell-command-with-editor-mode. But further stack trace is obfuscated by bytecompiled output. Recently I had to set (setq explicit-shell-file-name "bash") to be ...
0
votes
1answer
196 views

What is the keybinding for toggling between editing the shell contents as a buffer and running commands in it?

What is the keybinding for toggling between editing the shell contents as buffer on one hand and running commands in it on the other? I have configured multi-term to run bash and the shell is ...
1
vote
2answers
310 views

content was split in the functions of comint-preoutput-filter-functions

Consider the following snippet (defun python-shell-filter-long-lines (string) (print string) string) (push 'python-shell-filter-long-lines comint-preoutput-filter-functions) and M-x run-python ...
6
votes
2answers
2k views

how to name buffers (*shell*)

I'm interested in naming Emacs buffers. In particular I'd like to give names to shell buffers that I've started. That way I can easily tell them apart when switching buffers.
0
votes
1answer
760 views

Ansi-Term not reading .profile

my question is very similar to this one. I use my .profile file to set environment variables, such as EDITOR. However, when I run ansi-term and type printenv I can see that that variable is not ...
2
votes
1answer
2k views

Error running Emacs from a Terminal window: “Symbol's function definition is void: package-initialize”

After starting Emacs from a Terminal window, the following message is displayed: An error has occurred while loading '/Users/EvanAad/.emacs': Symbol's function definition is void: package-initialize ...
5
votes
2answers
660 views

How to determine the initial current directory when emacs is run from command line?

How can I determine (from within Emacs) the current directory as it was when the Shell launched emacs from the command line?
3
votes
1answer
709 views

MS Windows Tramp Remote Shell

I'm trying to open a remote shell after connecting to a machine using Tramp with the plink method on MS Windows. However every time I call shell it prompts me for 'Remote shell path' and suggests a ...
2
votes
1answer
327 views

how to print $HISTFILE?

I'm trying to print the path of $HISTFILE in emacs, but it doesn't work with (getenv "HISTFILE") or (shell-command-to-string "echo $HISTFILE"). It is working with $PATH and every other variable I've ...
1
vote
1answer
312 views

Remote shell (tramp) and login script

When I open a file via tramp on a remote machine and then start a shell with M-x shell I get an infinite loop because of my .cshrc file. I want to use a newer gcc version in CentOS so I have: set X="...
1
vote
0answers
446 views

Including pip-installed libraries on emacs python shell

I recently found out you can run python from emacs (Python Mode -> py-shell) and I've been running my scripts through the py-shell due to only needing to C-c C-c, but I've been running into a problem: ...
6
votes
5answers
2k views

How to start python shell in appropriate working directory?

If I am editing a python file, and start a python shell using elpy-shell-switch-to-shell the process appears to set the working directory as the containing directory of the file. However, the file ...
1
vote
0answers
119 views

`pushd` command for shell buffer

In an interactive shell, I have a script I run that changes my directory (via pushd) and then launches an interactive program. At this point I issue M-x cd and provide Emacs with the new directory ...
0
votes
1answer
107 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 ...
3
votes
1answer
292 views

Wrong indent with emacs 24 and 25 in shell-script-mode?

I get the following indentation for my bash script for i in *; { echo $i } echo done The last indent is wrong and should be zero spaces. How can this be fixed?
0
votes
3answers
561 views

What does trailing dash mean in the shell command parameter list?

This question is related to the solution nanny provides to the xml beautifying problem on this answer: How to prettify/format an XML buffer? This works for me on Emacs 24.5 on Windows, but I want to ...
1
vote
1answer
340 views

Startup script for term-mode

In the documentation for shell-mode: Emacs sends the new shell the contents of the file ~/.emacs_shellname as input, if it exists, where shellname is the name of the file that the shell was ...
0
votes
2answers
255 views

How can I start a server in the background from a source code block without freezing emacs?

I am creating several org-mode documents to track code example and would like to be able to view the results of tangling or executing these code blocks in a browser. In the example below, I've created ...
0
votes
0answers
27 views

dired function i wrote passes only current marked folder at point, can i send all marked folder?

i have this simple function i wrote (tbh i have zero coding skills.i gathered stuff from the web :)): (defun z/dired-media-filebot (file) (interactive (list (expand-file-name (dired-file-name-at-...
2
votes
1answer
411 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
0answers
352 views

ansi-term changes in line-mode not registered after char-mode

Here's the situation. I start M-x ansi-term, which launches it in term-char-mode. I type the following: echo "hello world" and press RET, which outputs on the next line the expected output hello ...
0
votes
1answer
113 views

How to run rspec from the emacs shell?

I'm following an entry-level tutorial on rspec here, and I've created a very simple test at spec\lib\zombie_spec.rb: require "spec_helper" describe "A Zombie" do #Your 'examples' (tests) go here. ...
3
votes
0answers
857 views

How to get Powerline colours working in Emacs Shell/Term mode?

I have recently started using Spacemacs instead of VIM, because of great VHDL mode. In vim (neovim) I used to use VIM as terminal emulator. In Emacs I have encountered a bit of strange colour ...
0
votes
1answer
493 views

Run 'TERM=ansi' when shell starts

I use shell inside emacs but by default it prints output in 1 color. However, when I use grep, I would like to see substring I'm searching highlighted. To see colors, I can manually type TERM=ansi ...
0
votes
1answer
137 views

Autocompletion of filename doesn't work in a shell in a buffer, when the current working directory is moved

In emacs, I press M-x shell to create a shell in a buffer. In the shell, I can use autocomplete file names with respect to the current working directory. If outside the shell e.g. in Nautilus, I ...
1
vote
1answer
521 views

auto kill a shell buffer when command finishes

i have this function you guys helped me write (defun z/dired-shell-other-window-beets () (interactive) (let ((command (concat "beet import " (format "%S" (dired-get-filename))))) (switch-...
-1
votes
2answers
387 views

How to run the last shell command from an python window?

I split the emacs into 2 windows, one window is used to edit the python code, say test.py, and another shell window to run shell command "python test.py", so each time after I edit the python, I need ...
0
votes
2answers
476 views

What is the proper way to pass variable strings to `shell-command-to-string`?

I have a shell script $ cat ~/foo.sh #!/bin/bash echo $1 $2 I'm trying to call this from emacs. My elisp function is (defun foo (word1 word2) "Print these two words." (interactive (list ...
2
votes
0answers
83 views

Evaluation of .dir-locals.el in shell?

I observed that directory local variables, defined in .dir-locals.el, are set for files, dired-buffers, new buffers, but not for shell or eshell buffers (well, that is also the case for buffers ...
0
votes
2answers
430 views

python emacs interpreter doesn't pause for input in loops

This looks like Weird shell output when using IPython 5, but it actually is not. I did set (setq python-shell-interpreter-args "--simple-prompt -i --pylab") in .emacs, but I get the following error:...
11
votes
2answers
6k views

.bash_profile or .bashrc for shell in emacs?

I wrote an alias for a huge command and stored it in .bash_profile and to my surprise, emacs didn't pick up the alias that I wrote in .bash_profile. After some searching in the internet, I created a ....
8
votes
2answers
3k views

How i can open shell in current buffer?

In function "shell" this line display shell buffer and almost always its open new shell in random frame. And I have to swap the buffers, it's annoying. ... (pop-to-buffer buffer) ... In docs says: ...
2
votes
3answers
755 views

How can Emacs set an environment/shell variable in a subordinate shell?

I often use subordinate shells within Emacs. (I instantiate these shells with M-x shell.) I put all these shells under auto-save-mode (through my shell-mode-hook; see below). Is there some way that ...
5
votes
3answers
138 views

How can I detect if an elisp script is piped?

I want to be able to tell whether stdout is a pipe in an elisp script. This would allow to distinguish between: $ emacs --script foo.el and $ emacs --script foo.el | cat Is this possible in Emacs ...
3
votes
1answer
6k views

How do i change the default shell for shell-command

I am having an issue with one of the plugins i am running because its trying to use fish and does not like the parameters. Is there a way i can change emacs to use bash for any plugins that use shell-...
1
vote
0answers
44 views

Since when the M-x shell open the shell on the other buffer?

I recently noticed the M-x shell command opens the shell in the other buffer. I used to do Ctrl-x 3 > Ctrl-x o > M-x shell. But recently I found that M-x shell opens the shell in the other buffer. ...
1
vote
1answer
77 views

How to create another instance of (e)shell in a DWIM fashion?

I have seen several proposals to run more than one instance of eshell (or shell) at a time. See here and here. However, they are inconvenient in my view, using peculiar key chords and forcing you to ...
4
votes
1answer
718 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 ...