I work on Mac OS X 10.5.8. I am trying to learn emacs. I am very new to it and today tried to enter shell commands from within emacs. I entered pdflatex filename
. However, it gives me an error saying
/bin/bash: pdflatex: command not found
I have LaTeX installed and pdflatex works fine from the command line in the terminal.
I get a similar error for a command lsd
that I have defined in my .bash_profile
file. This works fine too on the command line in the terminal.
The command ls
works fine in the emacs shell.
Does anyone have an idea what might be happening.
How I can get emacs to recognize all the commands that work fine on the command line in the terminal. Is there anyway I can make the environment used by emacs shell and terminal command line identical? If so, is there any reason you would recommend against doing so? I know very little of both bash and emacs.
Thank you very much.
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.
Eshell is a shell-like command interpreter implemented in Emacs Lisp. It invokes no external processes except for those requested by the user.
To get back into Emacs, type %emacs at the shell prompt. To quit Emacs permanently, type C-x C-c.
If you are working with a command line interface with no option to start GUI application, start Emacs directly in the terminal with emacs .
It's possible that the Emacs shell is working in a different environment from the one you have at the terminal command line. Compare the output of env
when run inside the Emacs shell and when run in the terminal. Pay particular attention to the values of PATH
.
From help for shell
command:
Program used comes from variable ‘explicit-shell-file-name’, or (if that is nil) from the ESHELL environment variable, or (if that is nil) from ‘shell-file-name’. If a file ‘~/.emacs_SHELLNAME’ exists, or ‘~/.emacs.d/init_SHELLNAME.sh’, it is given as initial input (but this may be lost, due to a timing error, if the shell discards input when it starts up). The buffer is put in Shell mode, giving commands for sending input and controlling the subjobs of the shell. See ‘shell-mode’. See also the variable ‘shell-prompt-pattern’.
So you can just create symlink ~/.emacs_bash
(for bash) or ~/.emacs_zsh
(for zsh). Alternatively set variable explicit-shell-file-name
to point to ~/.bash_profile
or ~/.bashrc
or ~/.zshrc
whichever you use or you can play which ESHELL
environment variable as well.
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