342 |
* Single Shell:: How to run one shell command and return. |
* Single Shell:: How to run one shell command and return. |
343 |
* Interactive Shell:: Permanent shell taking input via Emacs. |
* Interactive Shell:: Permanent shell taking input via Emacs. |
344 |
* Shell Mode:: Special Emacs commands used with permanent shell. |
* Shell Mode:: Special Emacs commands used with permanent shell. |
345 |
|
* Shell Prompts:: Two ways to recognize shell prompts. |
346 |
* History: Shell History. Repeating previous commands in a shell buffer. |
* History: Shell History. Repeating previous commands in a shell buffer. |
347 |
* Directory Tracking:: Keeping track when the subshell changes directory. |
* Directory Tracking:: Keeping track when the subshell changes directory. |
348 |
* Options: Shell Options. Options for customizing Shell mode. |
* Options: Shell Options. Options for customizing Shell mode. |
406 |
either or both of these default initializations.@refill |
either or both of these default initializations.@refill |
407 |
|
|
408 |
Both @kbd{M-!} and @kbd{M-|} wait for the shell command to complete, |
Both @kbd{M-!} and @kbd{M-|} wait for the shell command to complete, |
409 |
unless you end the command with @samp{&} to make it asyncronous. To |
unless you end the command with @samp{&} to make it asynchronous. To |
410 |
stop waiting, type @kbd{C-g} to quit; that terminates the shell |
stop waiting, type @kbd{C-g} to quit; that terminates the shell |
411 |
command with the signal @code{SIGINT}---the same signal that @kbd{C-c} |
command with the signal @code{SIGINT}---the same signal that @kbd{C-c} |
412 |
normally generates in the shell. Emacs waits until the command |
normally generates in the shell. Emacs waits until the command |
507 |
At end of buffer send line as input; otherwise, copy current line to |
At end of buffer send line as input; otherwise, copy current line to |
508 |
end of buffer and send it (@code{comint-send-input}). When a line is |
end of buffer and send it (@code{comint-send-input}). When a line is |
509 |
copied, any prompt at the beginning of the line (text output by |
copied, any prompt at the beginning of the line (text output by |
510 |
programs preceding your input) is omitted. (See also the variable |
programs preceding your input) is omitted. @xref{Shell Prompts}, for |
511 |
@code{comint-use-prompt-regexp-instead-of-fields}.) |
how Shell mode recognizes prompts. |
512 |
|
|
513 |
@item @key{TAB} |
@item @key{TAB} |
514 |
@kindex TAB @r{(Shell mode)} |
@kindex TAB @r{(Shell mode)} |
563 |
@kindex C-c C-u @r{(Shell mode)} |
@kindex C-c C-u @r{(Shell mode)} |
564 |
@findex comint-kill-input |
@findex comint-kill-input |
565 |
Kill all text pending at end of buffer to be sent as input |
Kill all text pending at end of buffer to be sent as input |
566 |
(@code{comint-kill-input}). |
(@code{comint-kill-input}). If point is not at end of buffer, |
567 |
|
this only kills the part of this text that precedes point. |
568 |
|
|
569 |
@item C-c C-w |
@item C-c C-w |
570 |
@kindex C-c C-w @r{(Shell mode)} |
@kindex C-c C-w @r{(Shell mode)} |
686 |
@end example |
@end example |
687 |
@end table |
@end table |
688 |
|
|
|
Shell mode also customizes the paragraph commands so that only shell |
|
|
prompts start new paragraphs. Thus, a paragraph consists of an input |
|
|
command plus the output that follows it in the buffer. |
|
|
|
|
689 |
@cindex Comint mode |
@cindex Comint mode |
690 |
@cindex mode, Comint |
@cindex mode, Comint |
691 |
Shell mode is a derivative of Comint mode, a general-purpose mode for |
Shell mode is a derivative of Comint mode, a general-purpose mode for |
702 |
in a subprocess using unmodified Comint mode---without the |
in a subprocess using unmodified Comint mode---without the |
703 |
specializations of Shell mode. |
specializations of Shell mode. |
704 |
|
|
705 |
|
@node Shell Prompts |
706 |
|
@subsection Shell Prompts |
707 |
|
|
708 |
|
@vindex shell-prompt-pattern |
709 |
|
@vindex comint-prompt-regexp |
710 |
|
@vindex comint-use-prompt-regexp |
711 |
|
@cindex prompt, shell |
712 |
|
A prompt is text output by a program to show that it is ready to |
713 |
|
accept new user input. Normally, Comint mode (and thus Shell mode) |
714 |
|
considers the prompt to be any text output by a program at the |
715 |
|
beginning of an input line. However, if the variable |
716 |
|
@code{comint-use-prompt-regexp} is non-@code{nil}, then Comint mode |
717 |
|
uses a regular expression to recognize prompts. In Shell mode, |
718 |
|
@code{shell-prompt-pattern} specifies the regular expression. |
719 |
|
|
720 |
|
The value of @code{comint-use-prompt-regexp} also affects many |
721 |
|
motion and paragraph commands. If the value is non-@code{nil}, the |
722 |
|
general Emacs motion commands behave as they normally do in buffers |
723 |
|
without special text properties. However, if the value is @code{nil}, |
724 |
|
the default, then Comint mode divides the buffer into two types of |
725 |
|
``fields'' (ranges of consecutive characters having the same |
726 |
|
@code{field} text property): input and output. Prompts are part of |
727 |
|
the output. Most Emacs motion commands do not cross field boundaries, |
728 |
|
unless they move over multiple lines. For instance, when point is in |
729 |
|
input on the same line as a prompt, @kbd{C-a} puts point at the |
730 |
|
beginning of the input if @code{comint-use-prompt-regexp} is |
731 |
|
@code{nil} and at the beginning of the line otherwise. |
732 |
|
|
733 |
|
In Shell mode, only shell prompts start new paragraphs. Thus, a |
734 |
|
paragraph consists of a prompt and the input and output that follow |
735 |
|
it. However, if @code{comint-use-prompt-regexp} is @code{nil}, the |
736 |
|
default, most paragraph commands do not cross field boundaries. This |
737 |
|
means that prompts, ranges of input, and ranges of non-prompt output |
738 |
|
behave mostly like separate paragraphs; with this setting, numeric |
739 |
|
arguments to most paragraph commands yield essentially undefined |
740 |
|
behavior. For the purpose of finding paragraph boundaries, Shell mode |
741 |
|
uses @code{shell-prompt-pattern}, regardless of |
742 |
|
@code{comint-use-prompt-regexp}. |
743 |
|
|
744 |
@node Shell History |
@node Shell History |
745 |
@subsection Shell Command History |
@subsection Shell Command History |
746 |
|
|
847 |
|
|
848 |
@vindex shell-input-ring-file-name |
@vindex shell-input-ring-file-name |
849 |
Some shells store their command histories in files so that you can |
Some shells store their command histories in files so that you can |
850 |
refer to previous commands from previous shell sessions. Emacs reads |
refer to commands from previous shell sessions. Emacs reads |
851 |
the command history file for your chosen shell, to initialize its own |
the command history file for your chosen shell, to initialize its own |
852 |
command history. The file name is @file{~/.bash_history} for bash, |
command history. The file name is @file{~/.bash_history} for bash, |
853 |
@file{~/.sh_history} for ksh, and @file{~/.history} for other shells. |
@file{~/.sh_history} for ksh, and @file{~/.history} for other shells. |
913 |
@key{SPC} perform history expansion by binding @key{SPC} to the |
@key{SPC} perform history expansion by binding @key{SPC} to the |
914 |
command @code{comint-magic-space}. |
command @code{comint-magic-space}. |
915 |
|
|
|
@vindex shell-prompt-pattern |
|
|
@vindex comint-prompt-regexp |
|
|
@vindex comint-use-prompt-regexp-instead-of-fields |
|
|
@cindex prompt, shell |
|
916 |
Shell mode recognizes history references when they follow a prompt. |
Shell mode recognizes history references when they follow a prompt. |
917 |
Normally, any text output by a program at the beginning of an input |
@xref{Shell Prompts}, for how Shell mode recognizes prompts. |
|
line is considered a prompt. However, if the variable |
|
|
@code{comint-use-prompt-regexp-instead-of-fields} is non-@code{nil}, |
|
|
then Comint mode uses a regular expression to recognize prompts. In |
|
|
general, the variable @code{comint-prompt-regexp} specifies the |
|
|
regular expression; Shell mode uses the variable |
|
|
@code{shell-prompt-pattern} to set up @code{comint-prompt-regexp} in |
|
|
the shell buffer. |
|
918 |
|
|
919 |
@node Directory Tracking |
@node Directory Tracking |
920 |
@subsection Directory Tracking |
@subsection Directory Tracking |
1145 |
happens automatically; there is no special password processing.) |
happens automatically; there is no special password processing.) |
1146 |
|
|
1147 |
When you log in to a different machine, you need to specify the type |
When you log in to a different machine, you need to specify the type |
1148 |
of terminal you're using. Terminal types @samp{ansi} or @samp{vt100} |
of terminal you're using, by setting the @env{TERM} environment |
1149 |
will work on most systems. |
variable in the environment for the remote login command. (If you use |
1150 |
|
bash, you do that by writing the variable assignment before the remote |
1151 |
|
login command, without separating comma.) Terminal types @samp{ansi} |
1152 |
|
or @samp{vt100} will work on most systems. |
1153 |
|
|
1154 |
@c If you are talking to a Bourne-compatible |
@c If you are talking to a Bourne-compatible |
1155 |
@c shell, and your system understands the @env{TERMCAP} variable, |
@c shell, and your system understands the @env{TERMCAP} variable, |
2107 |
paste (yank), and @kbd{C-z} undo. Standard Emacs commands like |
paste (yank), and @kbd{C-z} undo. Standard Emacs commands like |
2108 |
@kbd{C-x C-c} still work, because @kbd{C-x} and @kbd{C-c} only take |
@kbd{C-x C-c} still work, because @kbd{C-x} and @kbd{C-c} only take |
2109 |
effect when the mark is active. However, if you don't want these |
effect when the mark is active. However, if you don't want these |
2110 |
bindings at all, set @code{cua-enable-cua-keys} to nil. |
bindings at all, set @code{cua-enable-cua-keys} to @code{nil}. |
2111 |
|
|
2112 |
In CUA mode, using @kbd{Shift} together with the movement keys |
In CUA mode, using @kbd{Shift} together with the movement keys |
2113 |
activates the region over which they move. The standard (unshifted) |
activates the region over which they move. The standard (unshifted) |