Today I ran a command like this in the emacs shell:
./someBinary | grep foo | cut -c30- | sort | uniq -c
which in bash takes a bit but not that long (about 15 seconds) because the output is over a million lines easily. When I ran this command in the emacs shell, however, I waited over an hour and it's still running, with the processes visibly doing work if i check with top
. I wonder if this is because emacs implements the unix tools I am piping to in lisp - and if this is the reason, if there's a way to have it default to the system ones.
You can execute an external shell command from within Emacs using ` M-! ' ( 'shell-command' ). The output from the shell command is displayed in the minibuffer or in a separate buffer, depending on the output size.
Killing Emacs means terminating the Emacs program. To do this, type C-x C-c ( save-buffers-kill-terminal ). A two-character key sequence is used to make it harder to type by accident. If there are any modified file-visiting buffers when you type C-x C-c , Emacs first offers to save these buffers.
If the script is executable, you can execute it with C-c C-x ( executable-interpret ). You'll be given the opportunity to pass arguments. (This command works no matter what language the program is written in, by the way, as long as the file you're editing is executable.)
The keybindings for movement by word in Emacs is almost the same as that of movement by character, but instead of the prefix C- it is M- . To move forward one word use M-f ; and to move backward one word use M-b . Movement by word will make up the bulk of your intra-line movement.
Emacs is capturing the final output in the shell buffer, and applying font-lock and other analysis (line number counting, for example) to display it. It also scrolls the display to show the latest output. While Emacs has provisions for culling pathologically long command output, it's not really optimized for truly huge quantities of output counting in millions of lines, so it performs visibly worse than your terminal emulator, slowing down the whole pipeline.
If you're not interested in the output, redirect it to /dev/null
or to tail -500
, which is how much you'd see of it in a typical terminal scrollback anyway.
no, emacs does not implement those tools. that is running the same tools you run from the command line. however, the output is being passed through various pipes and probably has various formatting applied by emacs, which is most likely the culprit for the extreme slowdown. one easy thing to try would be disabling font-lock mode in the shell buffer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With