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
37
votes
2answers
7k views

Weird shell output when using IPython 5

I just upgraded to the latest version of IPython and now something is wrong when using it in emacs. When using it in a regular terminal it works fine (colors, tab-completion, etc.), however either ...
25
votes
1answer
602 views

What are all the ways of launching a shell from inside emacs and what are their various properties?

I know of at least four possibilities: eshell term ansi-term shell What's the complete list of tools built-in to emacs to launch a shell, and what benefits and drawbacks do they offer?
23
votes
3answers
3k views

How can I run an async process in the background without popping up a buffer?

I have defined some functions to run async background process using async-shell-command in my .emacs, but everytime I run the commands a new window (not frame) is created and the process' buffer is ...
17
votes
6answers
9k views

Emacs and command line $PATH disagreements on OSX

Having some issues with PATH settings on Emacs that are affecting my Haskell environment: I'm using ZSH, and when I go to the command line and call echo $PATH, it returns: /Users/g/Library/Haskell/...
14
votes
1answer
493 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
13
votes
2answers
4k views

Tramp mode is much slower than using terminal to ssh

I am using the Macports flavor of Emacs on OSX Yosemite, and have looked through every thread here on Tramp being slow without any solution. Tramp is usable, but there is about a 100ms delay between ...
11
votes
1answer
901 views

Attach to running remote shell with eshell/TRAMP/dtach

I often use GNU Screen to keep remote sessions alive. Since I live in Emacs, I'd really like to be able to resume a running remote shell session from within Emacs. GNU Screen implements all sorts of ...
10
votes
2answers
5k 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 ....
10
votes
1answer
137 views

How do I prevent one subprocess from starving others?

To be clear, I'm not talking about anything that should require emacs to be multithreaded (though that would probably also solve this). To reproduce: emacs -Q # I'm running 24.4.1 Make a second frame ...
9
votes
3answers
1k views

Any way to make prompts and previous-output uneditable in shell/term-mode?

This is admittedly a superficial question. Although ansi-term starts out behaving correctly when I first open it, it seems to degrade into an 'editable' mode after a few commands, e.g., when I do C-a ...
9
votes
4answers
2k views

How to make shell-command run using shell profile and current directory hooks (ex. direnv)

I am trying to get shell-command and async-shell-command to integrate seamlessly with a couple of programs in my .bashrc file, specifically direnv in this example. I found that if I customized shell-...
9
votes
3answers
6k views

Git Bash in emacs on Windows

I can run the Bash shell that comes with Git for Windows. I put this in my .emacs: (defun git-bash () (interactive) (let ((explicit-shell-file-name "D:/Program Files/git/bin/bash")) (call-...
9
votes
1answer
889 views

Is it possible to read user input from STDIN while tangling a source block?

Is it possible to read user input from STDIN while tangling a source block with org-babel-tangle? I am aware of this: Org Mode Babel - Interactive code block evaluation. That doesn't help solve this ...
8
votes
3answers
747 views

How to make a shell command totally silent (preventing it to split window or to open a new frame/window etc)

Is it possible to run a shell command silently (in background)? When I use async-shell-command, emacs split the windows. I would like that an specific shell command to be totally in background (...
8
votes
4answers
803 views

Async shell process buffer always clobbers window arrangement

I frequently launch external programs from emacs using M-!, such as Firefox or Evince, etc. Whenever I do, a buffer pops up full of results for the process, which clobbers whatever else I've got going ...
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: ...
8
votes
1answer
1k views

How to force an org-babel session to reset or initialize?

If I run the following babel shell blocks #+BEGIN_SRC sh :session one :results output ssh staging #+END_SRC #+BEGIN_SRC sh :session one :results output hostname #+END_SRC Org creates a shell ...
8
votes
1answer
1k views

How do I start a shell automatically after starting emacs

One of my main reasons for using Emacs is to get a powerful environment after sshing into a remote machine. The first thing I do after starting Emacs is to run M-x shell to get a command line. As it ...
8
votes
3answers
822 views

Persistent environment for M-x compile

When I run M-x compile it spawns a new subshell to execute my compile command. As soon as the compile command returns, the shell process is killed. I can see why this would be desirable in most cases, ...
7
votes
2answers
2k views

Flush all output in shell buffer (and *Messages* too)

Is there any easy way to flush all output in the shell buffer? Since recently (I believe Emacs 24.4 already has this) *shell* buffers aren't editable, they behave similar to how typical terminal would ...
7
votes
2answers
2k views

Should I have removed `(shell . t)` to clear an ob-shell initialization error?

First post. I'd like to confirmation whether I sucessfully troubleshooted an install of Emacs, and, if I didn't, direction on where and how to proceed. My setup: Emacs 24.5 Macbook Pro Core Duo (mid-...
7
votes
3answers
2k views

How to make terminal/shell spawned inside Emacs running on a Mac inherit the environment variables of the native terminal?

The terminal natively on Mac i.e. spawned through Spotlight or Launchpad, adopts the desired environment variables including the customization in ~/.bash_profile. But when I run Emacs (Emacs.app taken ...
7
votes
1answer
2k views

How to prevent Emacs from showing passphrase in `M-x shell`?

I tried using attic with a passphrase to backup my files from inside M-x shell. The shell exposed the passphrase as plain text in the buffer and made it available by typing M-r as well as by looking ...
7
votes
1answer
2k views

“terminal is not fully functional” over ssh in a *shell* buffer

I'm using the shell (M-x shell) to connect to a remote host via SSH. After launching some command line tools (mostly psql, the postgresql command line interface, but man would be the same for example),...
7
votes
2answers
3k views

How do you configure emacs for julia?

What is a recomended way for making emacs as julia code editor? The things which I would like to have are: autocomplete julia shell in emacs with abbility to send the code from buffer debugging
7
votes
1answer
687 views

File and directory autocompletion in remote shell

In my local shell, completion-at-point after cd returns a list of directories. However, when I ssh into a remote, Emacs thinks I'm still in my local home directory. How can I configure Emacs to give ...
7
votes
1answer
635 views

Change syntax highlighting without changing major mode?

I want to start a python-shell M-x python-shell. If I'm not happy with the syntax highlighting, is it possible to improve it (put more colors in the buffer) without changing major mode? In vim this ...
6
votes
2answers
373 views

Emacs is garbled by output of a background process running in the same terminal emulator

My Emacs is running in foreground in terminal emulator, where I am also running some background processes. My Emacs is garbled by the stdout and stderr output of the background process. Besides ...
6
votes
1answer
423 views

How can I keep dired in sync with a shell buffer?

I have some work that requires I move around between various sub-directories. Thus, the easiest way I have found to do that is to use dired. I also have to view some files (plain text or code), so ...
6
votes
4answers
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 ...
5
votes
2answers
3k views

How to open `shell` or `eshell` in a new window or frame

By M-x eshell or M-x shell Emacs opens a shell or an eshell in the current window. How to open this shell or eshell in a new window?
5
votes
1answer
221 views

M-x shell doesn't know about installed apps

I have to launch almost any application by specifying the whole path which is annoying. For example, git works fine, but lua does not. Both are installed in the same place: $ which git /usr/local/...
5
votes
2answers
986 views

Binding shell commands to hotkeys

Been scouring the internet for a couple days now trying to figure out the solution to my question with no luck. Hopefully someone here knows how to do this. I'm currently trying to set up my EMACS ...
5
votes
1answer
261 views

Difference between shell and term [duplicate]

I would like to understand what is the difference between M-x shell and M-x term? Also under which circumstances should be used the first and under which the second?
5
votes
3answers
133 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 ...
5
votes
1answer
233 views

Output to magit-process

When I run built-in magit commands, they output to the magit-process buffer. How can I do the same with a custom magit command that generates shell output?
5
votes
1answer
1k views

Why Emacs overrides my PATH when it runs bash?

Why do (shell-command-to-string "echo $PATH") and echo $PATH in eshell differ from echo $PATH from ansi-term and gnome terminal in Ubuntu? Some paths are missing from (shell-command-to-string "echo $...
5
votes
2answers
520 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?
5
votes
1answer
2k views

Org-babel invoking cmd.exe

Is there a simple configuration to get org-babel to invoke cmd.exe that doesn't involve modifying the org-babel source? Googling for ["org-babel" sh "cmd"] finds this email list discussion from 2010: ...
5
votes
1answer
575 views

Key binding with an argument

Say I have a shell command foo that I want to bind to a key. I could do for example: (global-set-key (kbd "C-c f") (lambda () (interactive) (shell-command "foo"))) I would like to be able to pass an ...
5
votes
3answers
444 views

How to autoscroll a window to always show the end of a growing buffer?

Context: I have a window that shows the output of a shell command. As new lines are added, I'd like the window to always show the most recent lines. Example: (let ((temp-window (or (get-buffer-...
5
votes
1answer
1k 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.
5
votes
2answers
442 views

Print process output line by line

Read process output line by line gives some partial ideas about how to deal with sub-process output in an intelligent manner, but no example and no working solution. I have a couple of examples, one ...
5
votes
1answer
1k views

Unwanted escape sequences in shell mode

Post title: Unwanted escape sequences in shell mode that are NOT due to colorizing-attempts (see update below) Any idea what can cause (unwanted) escape sequences to continue showing up in the ...
4
votes
1answer
800 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-...
4
votes
3answers
652 views

dirtrack mode with fish-shell

I recently started using the fish shell. I tried using it in term-mode in Emacs. One characteristic of this shell is that it shortens the current working directory before printing it as the prompt. ...
4
votes
2answers
61 views

How to pipe large files through fold before opening?

On a regular basis I need to open files that have really long lines, which unfortunately causes emacs to grind to a halt. My understanding is that this is a long-term issue with the renderer. I've ...
4
votes
1answer
133 views

Using pipe in a shell command

Say I am in dired and the pointer is on a file called test which contains: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. I type ! to run a shell command ...
4
votes
2answers
328 views

Discard stderr in start-process

I'm using start-process to run mplayer and when playing videos I get a ton of output to stderr from "vdp_...". On the command line I usually just 2>/dev/null but start-process runs it directly without ...
4
votes
2answers
452 views

What is the syntax for a subshell in eshell?

How to write the analogue of a bash-command like: (cd ../repo && git fast-export master) | darcs convert import repo_master in eshell? Here a subshell is employed to restrict the effect of ...