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 ...
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.
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
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 ...
Following a look at chronos.el
"-s 50 -k 1 -a 50 -v mb/mb-fr1")
should probably be:
'("-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 ...
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 ...
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.
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 ...
The following works with emacs26 on Ubuntu:
emacs file --eval "(add-hook 'emacs-startup-hook #'shell)"
Adding the function #'shell to emacs-startup-hook (instead of calling it with -f shell) defers the call to shell until the initialization of Emacs is complete.
That way the *shell*-buffer will be displayed in the window that is used for the *scratch* ...
The problem was in the .inputrc file (vi mode) with the following line:
As suggested in the jue's comment below, the following solves the problem by restoring the C-j to its original binding for dumb terminals such as the shell mode in Emacs:
Your value of PS1 contains ANSI escape codes that can only be processed correctly by a terminal emulator (like the built-in term.el or vterm), not by M-x shell or M-x eshell. Set it to something simpler like \u@\h:\w\$, this could be done with the -e switch for the docker-container-exec command.
M-x shell runs always a new shell asynchronously, which means a new connection. If you just need to run a command on the remote host, consider shell-command. Something like (shell-command "hostname") is an example for this.
Invoking M-x shell from a buffer with a remote file name should start a shell on the remote host.
The same thing applies to most commands which start a process.
how can i drop to a shell after i'm done finishing editing my conf file?
It sounds like you simply need to use M-x shell in that conf file's buffer.
You did not say for which buffer you want to set the default directory.
If you want to do it for the (existing) shell buffer with name *shell* try the following shell command:
emacsclient -e '(with-current-buffer "*shell*" (setq default-directory "/home/joe/system-test/auth/"))`
Pass the command line option -f to run a function with no arguments, or --eval to run an arbitrary Lisp expression.
To run a shell (whichever comes last is the one that's displayed in the Emacs window):
emacs filename.txt -f shell
emacs -f shell filename.txt
Here are examples to split the window or open two frames.
emacs -f shell -f split-window-...
In order to know that a buffer represents a remote connection, you can use file-remote-p.
You can read about this function Here
For example, in a shell buffer, (file-remote-p default-directory) will allow you to differentiate between a local shell and a remote shell.
In order to toggle company-mode, you can call the company-mode function with a parameter ...
You could use M-x compile with an appropriate compile-command value. e.g. as a file-local variable:
# -*- compile-command: "python file.py"; -*-
Emacs will prompt you to save (or not) the file before running the command.
Use M-! (M-x shell-command) if you want to run a shell command,
e.g. python file.py and print the output in a new buffer (*Shell
Command Output*). That does not open a shell in a new buffer.
Use M-x shell to run a shell in a new buffer as pointed by @NickD.
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)
You should start with Process Information:
(process-command (get-buffer-process "*Python*"))
==> ("python3" "-i")
(process-status (get-buffer-process "*Python*"))
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 ...
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 ...
As regards Linux, the behaviour can be controlled by with:
(setenv "LANG" ENCODING)
before calling M-x shell and after from the shell buffer with:
(set-buffer-process-coding-system INPUT-ENCODING OUTPUT-ENCODING)
Both should be set to a value compatible with the string to be represented. UTF-8 encoding family should work in most of the cases.