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."
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 ()
(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 ...
shell-mode-map is a variable that is defined in the file shell.el which is not loaded yet, so the variable is undefined.
Two common solutions:
(require 'shell) before you try use the variable. That loads the file into emacs, so the variable is now defined. You can then use it normally. If you have to do this with many libraries, that might slow down ...
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
$ 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.
Both return the same value when getenv is called on SSH_AUTH_SOCK from within an emacs client.
That looks unlikely. One would return ~/.ssh/ssh_auth_sock and the other would return /path/to/HOME/.ssh/ssh_auth_sock, no?
Have you tested whether SSH_AUTH_SOCK can actually contain ~ as a substitute for your HOME directory? Usually that would be expanded by a ...
Emacs can invoke processes either synchronously or asynchronously. In the former case, the calling program has to wait for the process to terminate before processing the entire output in one go (whether character-wise, line-wise, or other-wise is up to the program). In the latter case, the program can still wait for the process to terminate before processing ...
The variable shell-mode-map doesn't exist. Since it doesn't exist, define-key won't be able to add a key binding to it.
The solution you want is to wait until the variable exists, by deferring the call to define-key until later. Here's an example:
'(define-key shell-mode-map (kbd "C-c C-l") 'helm-comint-input-ring))
To suppress the warning first make sure the warnings library is loaded by entering M-x load-library RET warnings RET.
Then add the listed option to warning-suppress-types. Load the customization interface by entering M-x customize-option RET warning-suppress-types RET. Add a new top-level list-item by pressing the top-most INS button, then add two nested ...
:stdin isn't a argument as far as a function call is concerned. It's a special header argument which uses a slightly funky #+CALL syntax. Try:
#+CALL: my-shell-block[:stdin example-block1]()
Depending on your results setting you might want to force it to take output so it doesn't listify your results:
#+CALL: my-shell-block[:stdin example-block1 :results ...
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.:
(local-set-key "q" (lambda () (interactive) (kill-process)))...
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 ...
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)
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 ...
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.
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 ...
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 ...
Have you tried xterm-color ?
You can use the config below if you use use-package
(remove 'ansi-color-process-output comint-output-filter-functions))
(lambda () (add-hook 'comint-preoutput-filter-functions
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 ...
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)
The "after" advice does the actual work of switching to the other window - you might ...
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.
If you want the shell to always start from a specific directory, you can use the shell-mode-hook. Code stored in a mode hook is executed after the mode is loaded.
We want to send a command to change the directory once the shell process has started. There isn't a stock function to send commands to a shell process. However, there's a great StackOverflow ...
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 ...
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)
I would like to execute a script [...] every time I enter M-x shell
This is supported as standard.
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 loaded from. For example, if you use
bash, the file sent to it is ~/.emacs_bash. If this file is ...
M-x shell starts a shell inside a so-called dumb terminal. It can send and display text, but that's it. Anything fancy includes extra leg work.
What you'll want to use for the full interactive experience is M-x term. It supports all the bells and whistles of a terminal emulator, at the expense of being far slower than M-x shell.