Hot answers tagged

6

Because bash it is not the GUI program. Start your terminal emulator instead like (start-process "xterm" nil (executable-find "xterm"))


5

comint-send-string is the function you're looking for. (shell is built on top of the comint library.) It takes a PROCESS and a STRING. You can get the process from the shell buffer, and conveniently the shell function returns the buffer, so you can streamline it all into something like: (defun my-server () "SSH to my.server.com in `shell' buffer." (...


5

Here's a simple function that gets the pid of the process running in the current buffer and then calls the pstree command to get the process tree of that process: (defun iproc () (interactive) (let ((pid (process-id (get-buffer-process (current-buffer))))) (shell-command (format "pstree -p %d" pid)))) If I have a *shell* buffer running bash, run ...


4

Have emacs read from stdin device and insert contents into *scratch* buffer. $ fold -w80 myfile | emacs --insert /path/to/stdin Note: You will need to update /path/to/stdin path e.g. $ fold -w80 myfile | emacs --insert /dev/stdin This answer was validated using: emacs version: GNU Emacs 25.2.1 This question was used as a reference.


3

The Elisp code below makes ls output of eshell clickable. It is basing on a method proposed on emacswiki. If you click the mouse-button-2 (e.g., the middle mouse button/scroll-wheel) you get a pop up menu offering you to find the file in Emacs, to copy the file path, or to copy the path of the containing directory. (require 'em-ls) (require 'easymenu) (...


3

You can test the TERM environment variable in your bashrc file. For M-x shell it will be "dumb" as opposed to anything else. For ansi-term the TERM environment variable is set to "eterm-color".


2

From elisp you can set default-directory temporarily and then run your shell command: (let ((default-directory "/tmp")) (shell-command "ls"))


2

Note that script-proc-buffer will always be new-buffer since that is an existing buffer when make-comint-in-buffer is called. To bind kill-process to the key sequence q make it somehow interactive and use local-set-key with the wanted buffer current, e.g.: (with-current-buffer script-proc-buffer (local-set-key "q" (lambda () (interactive) (kill-process)))...


2

Emacs 26.1 provides the shell-command-dont-erase-buffer option, if you set it to end-last-out, M-! moves the point to the end of the output, however, it won't delete the previous commands' outputs, unlike the default behavior. (setq shell-command-dont-erase-buffer 'end-last-out)


2

The following Elisp code advises shell-command so that you can input a default-directory for the shell-command if you call it with numeric prefix argument. If the prefix argument is negative the original shell-command code will be called without prefix argument. You get the output of the shell command in *Shell Command Output* buffer in that case. If the ...


2

org-babel-execute:mermaid constructs its shell command like so: (concat (shell-quote-argument (expand-file-name ob-mermaid-cli-path)) " -i " (org-babel-process-file-name temp-file) " -o " (org-babel-process-file-name out-file)) So there isn't any facility to specify other options. The sensible thing to do is to submit a feature request or ...


2

I'm not familiar with mermaid, but did you consider making a wrapper script that has the arguments hard coded (assuming those arguments will not change)?


2

To run a command followed by an executable, the user may wish to use the &&. "&&" is used to chain commands together, such that the next command is run if and only if the preceding command exited without errors (or, more accurately, exits with a return code of 0). As such, the O.P. may wish to use either of the following: (compile "COMMAND ...


2

Inspired by @Melioratus. Currently, org-babel provides a hook called org-babel-after-execute-hook. I extended the supported arguments of org-babel src block by using it: (I'm using org-babel for elixir. If you want supports of other languages, extend cond by yourself.) (add-hook 'org-babel-after-execute-hook 'semacs/ob-args-ext-session-reset) (defun ...


2

This is hardcoded into the function sh-set-shell which is called when sh-mode is invoked. It's probably better to not touch that behaviour as it will also not display messages if it was not possible to set up indentation correctly. You can hide the message in the minibuffer (will still be displayed in Messages) by placing an advice around that function. (...


2

If you are using EShell the following works: man grep: Add "man" to the list value of eshell-visual-commands and use *man grep instead of man grep at the command line of Eshell. Background: The commands in eshell-visual-commands are started in term-mode which allows paging if the command does do that. man has an Eshell-own Elisp implementation eshell/man ...


2

Simply add your parameters to the command prompt, separated by space, without any placeholder for filenames. To construct commands like ls -l <file>, just enter ls -l. OR: the interface supports the placeholders * and ?. Where ? means call command with one marked file only, in a loop; and * means call with all marked files. Read more at ...


2

Following a look at chronos.el (setq chronos-text-to-speech-program-parameters "-s 50 -k 1 -a 50 -v mb/mb-fr1") should probably be: (setq chronos-text-to-speech-program-parameters '("-s" "50" "-k" "1" "-a" "50" "-v" "mb/mb-fr1")) It looks buggy in that it's not passing the arguments through shell-quote-argument, although it's unclear if ...


1

One way I discovered is to construct the command send to the bash process in such a way that after the execution the bash process gets stopped: (format "%s; kill -s STOP %s\n" command (process-id bash-process)) This way a process-sentinel can be used to detect when the execution is done and can enable the process again: (defun sentinel (proc status) (...


1

You should start with Process Information: (process-command (get-buffer-process "*Python*")) ==> ("python3" "-i") (process-status (get-buffer-process "*Python*")) ==> run You should not be running ftp and python under bash under Emacs, but rather use the specific modes for them (e.g., M-x run-python &c). If you insist on doing it your way, you ...


1

A few functions that might be useful here: (buffer-substring-no-properties BEG END) :: collect the buffer contents between BEG and END, two locations in the buffer (such as the beginning and end of a region), as a string (split-string STRING "\n") :: split STRING into a list of strings, broken at each linebreak (mapcar FUNCTION LIST) :: apply the function ...


1

I find a solution from here: http://wikemacs.org/wiki/Shell#Usage By default a shell session inside emacs via shell-mode won't persist accross sessions and won't read your shell's history. (add-hook 'shell-mode-hook 'my-shell-mode-hook) (defun my-shell-mode-hook () (setq comint-input-ring-file-name "~/.zsh_history") ;; or bash_history (comint-read-input-...


1

Not quite what you are asking for, but perhaps a helpful step in the right direction: the command shell-command, bound to M-! by default, allows you to run a shell command from Emacs. If you call it with a prefix argument, the output from that command is inserted at point in the current buffer. So, if you open a new buffer and invoke C-u M-! fold -w80 ./...


1

The quoted limitation does not exist any longer. Moreover, the function tramp-adb-handle-shell-command does not exist any longer. All different implementations of shell-command in Tramp have been unified in tramp-handle-shell-command, which is able to run several asynchronous processes in parallel. This is brand-new, it will appear with Tramp 2.4.2 (planned ...


1

I execute all of my python code through the shell within Emacs. Here is how I do it. Although it's not clear what specifically you're trying to call, I suspect that if you understand how this code works, you will be able to adapt it to your needs. Use the built-in Emacs help (C-h f and C-h v) to learn specifically what various parts of the code do. ...


1

Have you tried xterm-color ? You can use the config below if you use use-package (use-package xterm-color :config (setq comint-output-filter-functions (remove 'ansi-color-process-output comint-output-filter-functions)) (add-hook 'shell-mode-hook (lambda () (add-hook 'comint-preoutput-filter-functions ...


1

Don't try to test everything the same time. Concentrate first on Tramp. Start emacs -Q in order to suppress init files. Don't use any completion package, but load C-x C-f /ssh:myserver: directly. If this works, it isn't a Tramp issue, check the init files. If this doesn't work, start again emacs -Q, and evaluate in the *scratch* buffer (setq tramp-verbose ...


1

Oh, we can do this just by advising the comint-dynamic-list-input-ring function: (defadvice comint-dynamic-list-input-ring (before advice activate) (push ?\a unread-command-events)) (defadvice comint-dynamic-list-input-ring (after advice activate) (other-window 1)) The "after" advice does the actual work of switching to the other window - you might ...


1

The Tramp manual describes how to access a remote Windows machine. It uses Samba's smbclient program. A remote path looks like this: /smb:user%DOMAIN@machine:/share/path/to/file. The %DOMAIN part is optional. share is the name of a share on that machine. However, this is only the first part. Samba does not support to run remote processes on a Windows ...


1

Yes, if you want to make shell buffers limited in length, add the function comint-truncate-buffer to comint-output-filter-functions. You should be able to add this to your .emacs: (add-hook 'comint-output-filter-functions #'comint-truncate-buffer)


Only top voted, non community-wiki answers of a minimum length are eligible