diff options
| author | Aidan Gauland | 2013-02-08 09:59:24 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2013-02-08 09:59:24 -0500 |
| commit | dacbc44ca3fc825c9e5ffa799f1a0937c1da0020 (patch) | |
| tree | cff56a036c7abef2b9dce907eff83aadcfcc568a /doc/misc/eshell.texi | |
| parent | c220ea73ff3c6fa59b75837c950cc729295f2038 (diff) | |
| parent | c7205e538701bcfe2718e97429127a3a066d86c7 (diff) | |
| download | emacs-dacbc44ca3fc825c9e5ffa799f1a0937c1da0020.tar.gz emacs-dacbc44ca3fc825c9e5ffa799f1a0937c1da0020.zip | |
* doc/misc/eshell.texi: Fill most of the missing sections.
Diffstat (limited to 'doc/misc/eshell.texi')
| -rw-r--r-- | doc/misc/eshell.texi | 535 |
1 files changed, 397 insertions, 138 deletions
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index af457d7a9af..8d398900238 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | @c %**start of header | 2 | @c %**start of header |
| 3 | @setfilename ../../info/eshell | 3 | @setfilename ../../info/eshell |
| 4 | @settitle Eshell: The Emacs Shell | 4 | @settitle Eshell: The Emacs Shell |
| 5 | @defindex cm | ||
| 5 | @synindex vr fn | 6 | @synindex vr fn |
| 6 | @c %**end of header | 7 | @c %**end of header |
| 7 | 8 | ||
| @@ -42,7 +43,7 @@ modify this GNU manual.'' | |||
| 42 | @c -release- | 43 | @c -release- |
| 43 | @end ignore | 44 | @end ignore |
| 44 | @sp 3 | 45 | @sp 3 |
| 45 | @center John Wiegley | 46 | @center John Wiegley & Aidan Gauland |
| 46 | @c -date- | 47 | @c -date- |
| 47 | 48 | ||
| 48 | @page | 49 | @page |
| @@ -75,16 +76,15 @@ handling the sort of tasks accomplished by those tools. | |||
| 75 | * What is Eshell?:: A brief introduction to the Emacs Shell. | 76 | * What is Eshell?:: A brief introduction to the Emacs Shell. |
| 76 | * Command basics:: The basics of command usage. | 77 | * Command basics:: The basics of command usage. |
| 77 | * Commands:: | 78 | * Commands:: |
| 78 | * Arguments:: | 79 | * Expansion:: |
| 79 | * Input/Output:: | 80 | * Input/Output:: |
| 80 | * Process control:: | ||
| 81 | * Extension modules:: | 81 | * Extension modules:: |
| 82 | * Extras and Goodies:: | ||
| 83 | * Bugs and ideas:: Known problems, and future ideas. | 82 | * Bugs and ideas:: Known problems, and future ideas. |
| 84 | * GNU Free Documentation License:: The license for this documentation. | 83 | * GNU Free Documentation License:: The license for this documentation. |
| 85 | * Concept Index:: | 84 | * Concept Index:: |
| 86 | * Function and Variable Index:: | 85 | * Function and Variable Index:: |
| 87 | * Key Index:: | 86 | * Key Index:: |
| 87 | * Command Index:: | ||
| 88 | @end menu | 88 | @end menu |
| 89 | 89 | ||
| 90 | @node What is Eshell? | 90 | @node What is Eshell? |
| @@ -278,83 +278,56 @@ on your mind. Have fun! | |||
| 278 | @node Commands | 278 | @node Commands |
| 279 | @chapter Commands | 279 | @chapter Commands |
| 280 | 280 | ||
| 281 | In a command shell, everything is done by invoking commands. This | ||
| 282 | chapter covers command invocations in Eshell, including the command | ||
| 283 | history and invoking commands in a script file. | ||
| 284 | |||
| 281 | @menu | 285 | @menu |
| 282 | * Invocation:: | 286 | * Invocation:: |
| 283 | * Completion:: | 287 | * Arguments:: |
| 288 | * Variables:: | ||
| 289 | * Built-ins:: | ||
| 284 | * Aliases:: | 290 | * Aliases:: |
| 285 | * History:: | 291 | * History:: |
| 292 | * Completion:: | ||
| 293 | * for loop:: | ||
| 286 | * Scripts:: | 294 | * Scripts:: |
| 287 | * Built-ins:: | ||
| 288 | @end menu | 295 | @end menu |
| 289 | 296 | ||
| 290 | Essentially, a command shell is all about invoking commands---and | ||
| 291 | everything that entails. So understanding how Eshell invokes commands | ||
| 292 | is the key to comprehending how it all works. | ||
| 293 | |||
| 294 | @node Invocation | 297 | @node Invocation |
| 295 | @section Invocation | 298 | @section Invocation |
| 296 | |||
| 297 | Unlike regular system shells, Eshell never invokes kernel functions | 299 | Unlike regular system shells, Eshell never invokes kernel functions |
| 298 | directly, such as @code{exec(3)}. Instead, it uses the Lisp functions | 300 | directly, such as @code{exec(3)}. Instead, it uses the Lisp functions |
| 299 | available in the Emacs Lisp library. It does this by transforming the | 301 | available in the Emacs Lisp library. It does this by transforming the |
| 300 | command you specify into a callable Lisp form.@footnote{To see the Lisp | 302 | input line into a callable Lisp form.@footnote{To see the Lisp form that will be invoked, type: @samp{eshell-parse-command "echo hello"}} |
| 301 | form that will be invoked, type: @samp{eshell-parse-command "echo | 303 | |
| 302 | hello"}} | 304 | The command can be either an Elisp function or an external command. |
| 303 | 305 | Eshell looks first for an @ref{Aliases, alias} with the same name as the | |
| 304 | This transformation, from the string of text typed at the command | 306 | command, then a @ref{Built-ins, built-in command} or a function with the |
| 305 | prompt, to the ultimate invocation of either a Lisp function or external | 307 | same name; if there is no match, it then tries to execute it as an |
| 306 | command, follows these steps: | 308 | external command. |
| 307 | 309 | ||
| 308 | @enumerate | 310 | The semicolon (@code{;}) can be used to separate multiple command |
| 309 | @item Parse the command string into separate arguments. | 311 | invocations on a single line. A command invocation followed by an |
| 310 | @item | 312 | ampersand (@code{&}) will be run in the background. Eshell has no job |
| 311 | @end enumerate | 313 | control, so you can not suspend or background the current process, or |
| 312 | 314 | bring a background process into the foreground. That said, background | |
| 313 | @node Completion | 315 | processes invoked from Eshell can be controlled the same way as any |
| 314 | @section Completion | 316 | other background process in Emacs. |
| 315 | |||
| 316 | @node Aliases | ||
| 317 | @section Aliases | ||
| 318 | |||
| 319 | @node History | ||
| 320 | @section History | ||
| 321 | |||
| 322 | Eshell knows a few built-in variables: | ||
| 323 | |||
| 324 | @table @code | ||
| 325 | |||
| 326 | @item $+ | ||
| 327 | @vindex $+ | ||
| 328 | This variable always contains the current working directory. | ||
| 329 | |||
| 330 | @item $- | ||
| 331 | @vindex $- | ||
| 332 | This variable always contains the previous working directory (the | ||
| 333 | current working directory from before the last @code{cd} command). | ||
| 334 | |||
| 335 | @item $_ | ||
| 336 | @vindex $_ | ||
| 337 | It refers to the last argument of the last command. | ||
| 338 | |||
| 339 | @item $$ | ||
| 340 | @vindex $$ | ||
| 341 | This is the result of the last command. In case of an external | ||
| 342 | command, it is @code{t} or @code{nil}. | ||
| 343 | |||
| 344 | @item $? | ||
| 345 | @vindex $? | ||
| 346 | This variable contains the exit code of the last command (0 or 1 for | ||
| 347 | Lisp functions, based on successful completion). | ||
| 348 | |||
| 349 | @end table | ||
| 350 | |||
| 351 | @node Scripts | ||
| 352 | @section Scripts | ||
| 353 | 317 | ||
| 318 | @node Arguments | ||
| 319 | @section Arguments | ||
| 320 | Command arguments are passed to the functions as either strings or | ||
| 321 | numbers, depending on what the parser thinks they look like. If you | ||
| 322 | need to use a function that takes some other data type, you will need to | ||
| 323 | call it in an Elisp expression (which can also be used with | ||
| 324 | @ref{Expansion, expansions}). As with other shells, you can | ||
| 325 | escape special characters and spaces with the backslash (@code{\}) and | ||
| 326 | the single (@code{''}) and double (@code{""}) quotes. | ||
| 354 | 327 | ||
| 355 | @node Built-ins | 328 | @node Built-ins |
| 356 | @section Built-in commands | ||
| 357 | 329 | ||
| 330 | @section Built-in commands | ||
| 358 | Several commands are built-in in Eshell. In order to call the | 331 | Several commands are built-in in Eshell. In order to call the |
| 359 | external variant of a built-in command @code{foo}, you could call | 332 | external variant of a built-in command @code{foo}, you could call |
| 360 | @code{*foo}. Usually, this should not be necessary. You can check | 333 | @code{*foo}. Usually, this should not be necessary. You can check |
| @@ -368,7 +341,7 @@ eshell/ls is a compiled Lisp function in `em-ls.el' | |||
| 368 | @end example | 341 | @end example |
| 369 | 342 | ||
| 370 | If you want to discard a given built-in command, you could declare an | 343 | If you want to discard a given built-in command, you could declare an |
| 371 | alias, @ref{Aliases}. Eample: | 344 | alias, @ref{Aliases}. Example: |
| 372 | 345 | ||
| 373 | @example | 346 | @example |
| 374 | ~ $ which sudo | 347 | ~ $ which sudo |
| @@ -378,15 +351,96 @@ eshell/sudo is a compiled Lisp function in `em-unix.el' | |||
| 378 | sudo is an alias, defined as "*sudo $*" | 351 | sudo is an alias, defined as "*sudo $*" |
| 379 | @end example | 352 | @end example |
| 380 | 353 | ||
| 381 | Some of the built-in commands have a special behavior in Eshell: | 354 | @vindex eshell-prefer-lisp-functions |
| 355 | If you would prefer to use the built-in commands instead of the external | ||
| 356 | commands, set @var{eshell-prefer-lisp-functions} to @code{t}. | ||
| 357 | |||
| 358 | Some of the built-in commands have different behaviour from their | ||
| 359 | external counterparts, and some have no external counterpart. Most of | ||
| 360 | these will print a usage message when given the @code{--help} option. | ||
| 382 | 361 | ||
| 383 | @table @code | 362 | @table @code |
| 384 | 363 | ||
| 364 | @item addpath | ||
| 365 | @cmindex addpath | ||
| 366 | Adds a given path or set of paths to the PATH environment variable, or, | ||
| 367 | with no arguments, prints the current paths in this variable. | ||
| 368 | |||
| 369 | @item alias | ||
| 370 | @cmindex alias | ||
| 371 | Define an alias (@pxref{Aliases}). This does not add it to the aliases | ||
| 372 | file. | ||
| 373 | |||
| 374 | @item date | ||
| 375 | @cmindex date | ||
| 376 | Similar to, but slightly different from, the GNU Coreutils | ||
| 377 | @command{date} command. | ||
| 378 | |||
| 379 | @item define | ||
| 380 | @cmindex define | ||
| 381 | Define a varalias. @xref{Variable Aliases, , , elisp}. | ||
| 382 | |||
| 383 | @item diff | ||
| 384 | @cmindex diff | ||
| 385 | Use Emacs's internal @code{diff} (not to be confused with | ||
| 386 | @code{ediff}). @xref{Comparing Files, , , elisp}. | ||
| 387 | |||
| 388 | @item grep | ||
| 389 | @cmindex grep | ||
| 390 | @itemx agrep | ||
| 391 | @cmindex agrep | ||
| 392 | @itemx egrep | ||
| 393 | @cmindex egrep | ||
| 394 | @itemx fgrep | ||
| 395 | @cmindex fgrep | ||
| 396 | @itemx glimpse | ||
| 397 | @cmindex glimpse | ||
| 398 | The @command{grep} commands are compatible with GNU @command{grep}, but | ||
| 399 | use Emacs's internal @code{grep} instead. | ||
| 400 | |||
| 401 | @item info | ||
| 402 | @cmindex info | ||
| 403 | Same as the external @command{info} command, but uses Emacs's internal | ||
| 404 | Info reader. | ||
| 405 | |||
| 406 | @item jobs | ||
| 407 | @cmindex jobs | ||
| 408 | List subprocesses of the Emacs process, if any, using the function | ||
| 409 | @code{list-processes}. | ||
| 410 | |||
| 411 | @item kill | ||
| 412 | @cmindex kill | ||
| 413 | Kill processes. Takes a PID or a process object and an optional | ||
| 414 | signal specifier. | ||
| 415 | |||
| 416 | @item listify | ||
| 417 | @cmindex listify | ||
| 418 | Eshell version of @code{list}. Allows you to create a list using Eshell | ||
| 419 | syntax, rather than Elisp syntax. For example, @samp{listify foo bar} | ||
| 420 | and @code{("foo" "bar")} both evaluate to @code{("foo" "bar")}. | ||
| 421 | |||
| 422 | @item locate | ||
| 423 | @cmindex locate | ||
| 424 | Alias to Emacs's @code{locate} function, which simply runs the external | ||
| 425 | @command{locate} command and parses the results. @xref{Dired and `find', , , elisp}. | ||
| 426 | |||
| 427 | @item make | ||
| 428 | @cmindex make | ||
| 429 | Run @command{make} through @code{compile}. @xref{Running Compilations under Emacs, , , elisp}. | ||
| 430 | |||
| 431 | @item occur | ||
| 432 | @cmindex occur | ||
| 433 | Alias to Emacs's @code{occur}. @xref{Other Search-and-Loop Commands, , , elisp}. | ||
| 434 | |||
| 435 | @item printnl | ||
| 436 | @cmindex printnl | ||
| 437 | Print the arguments separated by newlines. | ||
| 438 | |||
| 385 | @item cd | 439 | @item cd |
| 386 | @findex cd | 440 | @cmindex cd |
| 387 | This command changes the current working directory. Usually, it is | 441 | This command changes the current working directory. Usually, it is |
| 388 | invoked as @samp{cd foo} where @file{foo} is the new working | 442 | invoked as @samp{cd foo} where @file{foo} is the new working directory. |
| 389 | directory. But @code{cd} knows about a few special arguments: | 443 | But @command{cd} knows about a few special arguments: |
| 390 | 444 | ||
| 391 | When it receives no argument at all, it changes to the home directory. | 445 | When it receives no argument at all, it changes to the home directory. |
| 392 | 446 | ||
| @@ -396,14 +450,73 @@ directory (this is the same as @samp{cd $-}). | |||
| 396 | The command @samp{cd =} shows the directory stack. Each line is | 450 | The command @samp{cd =} shows the directory stack. Each line is |
| 397 | numbered. | 451 | numbered. |
| 398 | 452 | ||
| 399 | With @samp{cd =foo}, Eshell searches the directory stack for a | 453 | With @samp{cd =foo}, Eshell searches the directory stack for a directory |
| 400 | directory matching the regular expression @samp{foo} and changes to | 454 | matching the regular expression @samp{foo} and changes to that |
| 401 | that directory. | 455 | directory. |
| 402 | 456 | ||
| 403 | With @samp{cd -42}, you can access the directory stack by number. | 457 | With @samp{cd -42}, you can access the directory stack by number. |
| 404 | 458 | ||
| 405 | @item history | 459 | @item su |
| 406 | @findex history | 460 | @cmindex su |
| 461 | @itemx sudo | ||
| 462 | @cmindex sudo | ||
| 463 | Uses TRAMP's @command{su} or @command{sudo} method to run a command via | ||
| 464 | @command{su} or @command{sudo}. | ||
| 465 | |||
| 466 | @end table | ||
| 467 | |||
| 468 | @section Built-in variables | ||
| 469 | Eshell knows a few built-in variables: | ||
| 470 | |||
| 471 | @table @code | ||
| 472 | |||
| 473 | @item $+ | ||
| 474 | @vindex $+ | ||
| 475 | This variable always contains the current working directory. | ||
| 476 | |||
| 477 | @item $- | ||
| 478 | @vindex $- | ||
| 479 | This variable always contains the previous working directory (the | ||
| 480 | current working directory from before the last @code{cd} command). | ||
| 481 | |||
| 482 | @item $_ | ||
| 483 | @vindex $_ | ||
| 484 | It refers to the last argument of the last command. | ||
| 485 | |||
| 486 | @item $$ | ||
| 487 | @vindex $$ | ||
| 488 | This is the result of the last command. In case of an external | ||
| 489 | command, it is @code{t} or @code{nil}. | ||
| 490 | |||
| 491 | @item $? | ||
| 492 | @vindex $? | ||
| 493 | This variable contains the exit code of the last command (0 or 1 for | ||
| 494 | Lisp functions, based on successful completion). | ||
| 495 | |||
| 496 | @end table | ||
| 497 | |||
| 498 | @node Variables | ||
| 499 | @section Variables | ||
| 500 | Since Eshell is just an Emacs REPL@footnote{Read-Eval-Print Loop}, it | ||
| 501 | does not have its own scope, and simply stores variables the same you | ||
| 502 | would in an Elisp program. Eshell provides a command version of | ||
| 503 | @code{setq} for convenience. | ||
| 504 | |||
| 505 | @node Aliases | ||
| 506 | @section Aliases | ||
| 507 | |||
| 508 | Aliases are commands that expand to a longer input line. For example, | ||
| 509 | @command{ll} is a common alias for @code{ls -l}, and would be defined | ||
| 510 | with the command invocation @samp{alias ll ls -l}; with this defined, | ||
| 511 | running @samp{ll foo} in Eshell will actually run @samp{ls -l foo}. | ||
| 512 | Aliases defined (or deleted) by the @command{alias} command are | ||
| 513 | automatically written to the file named by @var{eshell-aliases-file}, | ||
| 514 | which you can also edit directly (although you will have to manually | ||
| 515 | reload it). | ||
| 516 | |||
| 517 | @node History | ||
| 518 | @section History | ||
| 519 | @cmindex history | ||
| 407 | The @samp{history} command shows all commands kept in the history ring | 520 | The @samp{history} command shows all commands kept in the history ring |
| 408 | as numbered list. If the history ring contains | 521 | as numbered list. If the history ring contains |
| 409 | @code{eshell-history-size} commands, those numbers change after every | 522 | @code{eshell-history-size} commands, those numbers change after every |
| @@ -419,70 +532,226 @@ of the history ring. | |||
| 419 | argument of the last command beginning with @code{foo} is accessible | 532 | argument of the last command beginning with @code{foo} is accessible |
| 420 | by @code{!foo:n}. | 533 | by @code{!foo:n}. |
| 421 | 534 | ||
| 422 | @item su | 535 | The history ring is loaded from a file at the start of every session, |
| 423 | @findex su | 536 | and written back to the file at the end of every session. The file path |
| 424 | @itemx sudo | 537 | is specified in @var{eshell-history-file-name}. Unlike other shells, |
| 425 | @findex sudo | 538 | such as Bash, Eshell can not be configured to keep a history ring of a |
| 426 | @code{su} and @code{sudo} work as expected: they apply the following | 539 | different size than that of the history file. |
| 427 | commands (@code{su}), or the command being an argument (@code{sudo}) | 540 | |
| 428 | under the permissions of somebody else. | 541 | Since the default buffer navigation and searching key-bindings are |
| 429 | 542 | still present in the Eshell buffer, the commands for history | |
| 430 | This does not work only on | 543 | navigation and searching are bound to different keys: |
| 431 | the local host, but even on a remote one, when | 544 | |
| 432 | @code{default-directory} is a remote file name. The necessary | 545 | @table @kbd |
| 433 | proxy configuration of Tramp is performed | 546 | @item M-r |
| 434 | @ifinfo | 547 | @itemx M-s |
| 435 | automatically, @ref{Multi-hops, , , tramp}. | 548 | History I-search. |
| 436 | @end ifinfo | 549 | |
| 437 | @ifnotinfo | 550 | @item M-p |
| 438 | automatically. | 551 | @itemx M-n |
| 439 | @end ifnotinfo | 552 | Previous and next history line. If there is anything on the input |
| 440 | Example: | 553 | line when you run these commands, they will instead jump to the |
| 554 | precious or next line that begins with that string. | ||
| 555 | @end table | ||
| 556 | |||
| 557 | @node Completion | ||
| 558 | @section Completion | ||
| 559 | Eshell uses the pcomplete package for programmable completion, similar | ||
| 560 | to that of other command shells. Argument completion differs depending | ||
| 561 | on the preceding command: for example, possible completions for | ||
| 562 | @command{rmdir} are only directories, while @command{rm} completions can | ||
| 563 | be directories @emph{and} files. Eshell provides predefined completions | ||
| 564 | for the built-in functions and some common external commands, and you | ||
| 565 | can define your own for any command. | ||
| 566 | |||
| 567 | Eshell completion also works for lisp forms and glob patterns. If the | ||
| 568 | point is on a lisp form, then @key{TAB} will behave similarly to completion | ||
| 569 | in @code{elisp-mode} and @code{lisp-interaction-mode}. For glob | ||
| 570 | patterns, If there are few enough possible completions of the patterns, | ||
| 571 | they will be cycled when @key{TAB} is pressed, otherwise it will be removed | ||
| 572 | from the input line and the possible completions will be listed. | ||
| 573 | |||
| 574 | If you want to see the entire list of possible completions when it's | ||
| 575 | below the cycling threshold, press @kbd{M-?}. | ||
| 576 | |||
| 577 | @subsection pcomplete | ||
| 578 | Pcomplete, short for programmable completion, is the completion | ||
| 579 | library originally written for Eshell, but usable for command | ||
| 580 | completion@footnote{Command completion as opposed to code completion, | ||
| 581 | which is a beyond the scope of pcomplete.} in other modes. | ||
| 582 | |||
| 583 | Completions are defined as functions (with @code{defun}) named | ||
| 584 | @code{pcomplete/COMMAND}, where @code{COMMAND} is the name of the | ||
| 585 | command for which this function provides completions; you can also name | ||
| 586 | the function @code{pcomplete/MAJOR-MODE/COMMAND} to define completions | ||
| 587 | for a specific major mode. | ||
| 588 | |||
| 589 | @node for loop | ||
| 590 | @section @code{for} loop | ||
| 591 | Because Eshell commands can not (easily) be combined with lisp forms, | ||
| 592 | Eshell provides a command-oriented @command{for}-loop for convenience. | ||
| 593 | The syntax is as follows: | ||
| 441 | 594 | ||
| 442 | @example | 595 | @example |
| 443 | ~ $ cd /ssh:otherhost:/etc | 596 | @code{for VAR in TOKENS @{ command invocation(s) @}} |
| 444 | /ssh:user@@otherhost:/etc $ sudo find-file shadow | ||
| 445 | @end example | 597 | @end example |
| 446 | 598 | ||
| 447 | @end table | 599 | where @samp{TOKENS} is a space-separated sequence of values of |
| 448 | 600 | @var{VAR} for each iteration. This can even be the output of a | |
| 601 | command if @samp{TOKENS} is replaced with @samp{@{ command invocation @}}. | ||
| 449 | 602 | ||
| 450 | @node Arguments | 603 | @node Scripts |
| 451 | @chapter Arguments | 604 | @section Scripts |
| 605 | @cmindex source | ||
| 606 | @fnindex eshell-source-file | ||
| 607 | You can run Eshell scripts much like scripts for other shells; the main | ||
| 608 | difference is that since Eshell is not a system command, you have to run | ||
| 609 | it from within Emacs. An Eshell script is simply a file containing a | ||
| 610 | sequence of commands, as with almost any other shell script. Scripts | ||
| 611 | are invoked from Eshell with @command{source}, or from anywhere in Emacs | ||
| 612 | with @code{eshell-source-file}. | ||
| 613 | |||
| 614 | @cmindex . | ||
| 615 | If you wish to load a script into your @emph{current} environment, | ||
| 616 | rather than in a subshell, use the @code{.} command. | ||
| 617 | |||
| 618 | @node Expansion | ||
| 619 | @chapter Expansion | ||
| 620 | Expansion in a command shell is somewhat like macro expansion in macro | ||
| 621 | parsers (such as @command{cpp} and @command{m4}), but in a command | ||
| 622 | shell, they are less often used for constants, and usually for using | ||
| 623 | variables and string manipulation.@footnote{Eshell has no | ||
| 624 | string-manipulation expansions because the Elisp library already | ||
| 625 | provides many functions for this.} For example, @code{$var} on a line | ||
| 626 | expands to the value of the variable @code{var} when the line is | ||
| 627 | executed. Expansions are usually passed as arguments, but may also be | ||
| 628 | used as commands.@footnote{e.g. Entering just @samp{$var} at the prompt | ||
| 629 | is equivalent to entering the value of @code{var} at the prompt.} | ||
| 452 | 630 | ||
| 453 | @menu | 631 | @menu |
| 454 | * The Parser:: | 632 | * Dollars Expansion:: |
| 455 | * Variables:: | ||
| 456 | * Substitution:: | ||
| 457 | * Globbing:: | 633 | * Globbing:: |
| 458 | * Predicates:: | ||
| 459 | @end menu | 634 | @end menu |
| 460 | 635 | ||
| 461 | @node The Parser | 636 | @node Dollars Expansion |
| 462 | @section The Parser | 637 | @section Dollars Expansion |
| 638 | Eshell has different @code{$} expansion syntax from other shells. There | ||
| 639 | are some similarities, but don't let these lull you into a false sense | ||
| 640 | of familiarity. | ||
| 463 | 641 | ||
| 464 | @node Variables | 642 | @table @code |
| 465 | @section Variables | ||
| 466 | 643 | ||
| 467 | @node Substitution | 644 | @item $var |
| 468 | @section Substitution | 645 | Expands to the value bound to @code{var}. This is the main way to use |
| 646 | variables in command invocations. | ||
| 469 | 647 | ||
| 470 | @node Globbing | 648 | @item $#var |
| 471 | @section Globbing | 649 | Expands to the length of the value bound to @code{var}. Raises an error |
| 650 | if the value is not a sequence (@pxref{Sequences Arrays and Vectors, Sequences, , elisp}). | ||
| 472 | 651 | ||
| 473 | @node Predicates | 652 | @item $(lisp) |
| 474 | @section Predicates | 653 | Expands to the result of evaluating the S-expression @code{(lisp)}. On |
| 654 | its own, this is identical to just @code{(lisp)}, but with the @code{$}, | ||
| 655 | it can be used in a string, such as @samp{/some/path/$(lisp).txt}. | ||
| 475 | 656 | ||
| 657 | @item $@{command@} | ||
| 658 | Returns the output of @command{command}, which can be any valid Eshell | ||
| 659 | command invocation, and may even contain expansions. | ||
| 476 | 660 | ||
| 477 | @node Input/Output | 661 | @item $var[i] |
| 478 | @chapter Input/Output | 662 | Expands to the @code{i}th element of the value bound to @code{var}. If |
| 663 | the value is a string, it will be split at whitespace to make it a list. | ||
| 664 | Again, raises an error if the value is not a sequence. | ||
| 665 | |||
| 666 | @item $var[: i] | ||
| 667 | As above, but now splitting occurs at the colon character. | ||
| 479 | 668 | ||
| 480 | @node Process control | 669 | @item $var[: i j] |
| 481 | @chapter Process control | 670 | As above, but instead of returning just a string, it now returns a list |
| 671 | of two strings. If the result is being interpolated into a larger | ||
| 672 | string, this list will be flattened into one big string, with each | ||
| 673 | element separated by a space. | ||
| 482 | 674 | ||
| 675 | @item $var["\\\\" i] | ||
| 676 | Separate on backslash characters. Actually, the first argument -- if it | ||
| 677 | doesn't have the form of a number, or a plain variable name -- can be | ||
| 678 | any regular expression. So to split on numbers, use @samp{$var["[0-9]+" 10 20]}. | ||
| 679 | |||
| 680 | @item $var[hello] | ||
| 681 | Calls @code{assoc} on @code{var} with @code{"hello"}, expecting it to be | ||
| 682 | an alist (@pxref{Association List Type, Association Lists, , elisp}). | ||
| 683 | |||
| 684 | @item $#var[hello] | ||
| 685 | Returns the length of the cdr of the element of @code{var} who car is equal | ||
| 686 | to @code{"hello"}. | ||
| 687 | |||
| 688 | @end table | ||
| 689 | |||
| 690 | @node Globbing | ||
| 691 | @section Globbing | ||
| 692 | Eshell's globbing syntax is very similar to that of Zsh. Users coming | ||
| 693 | from Bash can still use Bash-style globbing, as there are no | ||
| 694 | incompatibilities. Most globbing is pattern-based expansion, but there | ||
| 695 | is also predicate-based expansion. See @ref{Filename Generation, , , zsh} | ||
| 696 | for full syntax. To customize the syntax and behaviour of globbing in | ||
| 697 | Eshell see the Customize@footnote{@xref{Customization Settings, Customize, , elisp}.} | ||
| 698 | groups ``eshell-glob'' and ``eshell-pred''. | ||
| 699 | |||
| 700 | @node Input/Output | ||
| 701 | @chapter Input/Output | ||
| 702 | Since Eshell does not communicate with a terminal like most command | ||
| 703 | shells, IO is a little different. If you try to run programs from | ||
| 704 | within Eshell that are not line-oriented, such as programs that use | ||
| 705 | ncurses, you will just get garbage output, since the Eshell buffer is | ||
| 706 | not a terminal emulator. Eshell solves this problem by running | ||
| 707 | specified commands in Emacs's terminal emulator; to let Eshell know | ||
| 708 | which commands need to be run in a terminal, add them to the list | ||
| 709 | @var{eshell-visual-commands}. | ||
| 710 | |||
| 711 | Redirection is mostly the same in Eshell as it is in other command | ||
| 712 | shells. The output redirection operators @code{>} and @code{>>} as well | ||
| 713 | as pipes are supported, but there is not yet any support for input | ||
| 714 | redirection. Output can also be redirected to Elisp functions, using | ||
| 715 | virtual devices. | ||
| 716 | |||
| 717 | @var{eshell-virtual-targets} is a list of mappings of virtual device | ||
| 718 | names to functions. Eshell comes with two virtual devices: | ||
| 719 | @file{/dev/kill}, which sends the text to the kill ring, and | ||
| 720 | @file{/dev/clip}, which sends text to the clipboard. | ||
| 721 | |||
| 722 | You can, of course, define your own virtual targets. They are defined | ||
| 723 | by adding a list of the form @code{("/dev/name" function mode)} to | ||
| 724 | @var{eshell-virtual-targets}. The first element is the device name; | ||
| 725 | @code{function} may be either a lambda or a function name. If | ||
| 726 | @code{mode} is nil, then the function is the output function; if it is | ||
| 727 | non-nil, then the function is passed the redirection mode as a | ||
| 728 | symbol--@code{overwrite}, @code{append}, or @code{insert}--and the | ||
| 729 | function is expected to return the output function. | ||
| 730 | |||
| 731 | The output function is called once on each line of output until | ||
| 732 | @code{nil} is passed, indicating end of output. | ||
| 483 | 733 | ||
| 484 | @node Extension modules | 734 | @node Extension modules |
| 485 | @chapter Extension modules | 735 | @chapter Extension modules |
| 736 | Eshell provides a facility for defining extension modules so that they | ||
| 737 | can be disabled and enabled without having to unload and reload them, | ||
| 738 | and to provide a common parent Customize group for the | ||
| 739 | modules.@footnote{ERC provides a similar module facility.} An Eshell | ||
| 740 | module is defined the same as any other library but one requirement: the | ||
| 741 | module must define a Customize@footnote{@xref{Customization Settings, Customize, , elisp}.} | ||
| 742 | group using @code{eshell-defgroup} (in place of @code{defgroup}) with | ||
| 743 | @code{eshell-module} as the parent group.@footnote{If the module has | ||
| 744 | no user-customizable options, then there is no need to define it as an | ||
| 745 | Eshell module.} You also need to load the following as shown: | ||
| 746 | |||
| 747 | @example | ||
| 748 | (eval-when-compile | ||
| 749 | (require 'cl) | ||
| 750 | (require 'esh-mode) | ||
| 751 | (require 'eshell)) | ||
| 752 | |||
| 753 | (require 'esh-util) | ||
| 754 | @end example | ||
| 486 | 755 | ||
| 487 | @menu | 756 | @menu |
| 488 | * Writing a module:: | 757 | * Writing a module:: |
| @@ -491,7 +760,6 @@ Example: | |||
| 491 | * Key rebinding:: | 760 | * Key rebinding:: |
| 492 | * Smart scrolling:: | 761 | * Smart scrolling:: |
| 493 | * Terminal emulation:: | 762 | * Terminal emulation:: |
| 494 | * Built-in UNIX commands:: | ||
| 495 | @end menu | 763 | @end menu |
| 496 | 764 | ||
| 497 | @node Writing a module | 765 | @node Writing a module |
| @@ -512,13 +780,6 @@ Example: | |||
| 512 | @node Terminal emulation | 780 | @node Terminal emulation |
| 513 | @section Terminal emulation | 781 | @section Terminal emulation |
| 514 | 782 | ||
| 515 | @node Built-in UNIX commands | ||
| 516 | @section Built-in UNIX commands | ||
| 517 | |||
| 518 | |||
| 519 | @node Extras and Goodies | ||
| 520 | @chapter Extras and Goodies | ||
| 521 | |||
| 522 | @node Bugs and ideas | 783 | @node Bugs and ideas |
| 523 | @chapter Bugs and ideas | 784 | @chapter Bugs and ideas |
| 524 | @cindex reporting bugs and ideas | 785 | @cindex reporting bugs and ideas |
| @@ -527,6 +788,8 @@ Example: | |||
| 527 | @cindex email to the author | 788 | @cindex email to the author |
| 528 | @cindex FAQ | 789 | @cindex FAQ |
| 529 | @cindex problems, list of common | 790 | @cindex problems, list of common |
| 791 | @cindex known bugs | ||
| 792 | @cindex bugs, known | ||
| 530 | 793 | ||
| 531 | If you find a bug or misfeature, don't hesitate to let me know! Send | 794 | If you find a bug or misfeature, don't hesitate to let me know! Send |
| 532 | email to @email{johnw@@gnu.org}. Feature requests should also be sent | 795 | email to @email{johnw@@gnu.org}. Feature requests should also be sent |
| @@ -537,16 +800,7 @@ If you have ideas for improvements, or if you have written some | |||
| 537 | extensions to this package, I would like to hear from you. I hope you | 800 | extensions to this package, I would like to hear from you. I hope you |
| 538 | find this package useful! | 801 | find this package useful! |
| 539 | 802 | ||
| 540 | @menu | 803 | Below is a complete list of known problems with Eshell version 2.4.2, |
| 541 | * Known problems:: | ||
| 542 | @end menu | ||
| 543 | |||
| 544 | @node Known problems | ||
| 545 | @section Known problems | ||
| 546 | @cindex known bugs | ||
| 547 | @cindex bugs, known | ||
| 548 | |||
| 549 | Below is complete list of known problems with Eshell version 2.4.2, | ||
| 550 | which is the version included with Emacs 22. | 804 | which is the version included with Emacs 22. |
| 551 | 805 | ||
| 552 | @table @asis | 806 | @table @asis |
| @@ -554,7 +808,7 @@ which is the version included with Emacs 22. | |||
| 554 | 808 | ||
| 555 | @item Differentiate between aliases and functions | 809 | @item Differentiate between aliases and functions |
| 556 | 810 | ||
| 557 | Allow for a bash-compatible syntax, such as: | 811 | Allow for a Bash-compatible syntax, such as: |
| 558 | 812 | ||
| 559 | @example | 813 | @example |
| 560 | alias arg=blah | 814 | alias arg=blah |
| @@ -838,7 +1092,7 @@ them; @code{min} would display the smallest figure, etc. | |||
| 838 | It would provide syntax, abbrev, highlighting and indenting support like | 1092 | It would provide syntax, abbrev, highlighting and indenting support like |
| 839 | @code{emacs-lisp-mode} and @code{shell-mode}. | 1093 | @code{emacs-lisp-mode} and @code{shell-mode}. |
| 840 | 1094 | ||
| 841 | @item In the history mechanism, finish the @command{bash}-style support | 1095 | @item In the history mechanism, finish the Bash-style support |
| 842 | 1096 | ||
| 843 | This means @samp{!n}, @samp{!#}, @samp{!:%}, and @samp{!:1-} as separate | 1097 | This means @samp{!n}, @samp{!#}, @samp{!:%}, and @samp{!:1-} as separate |
| 844 | from @samp{!:1*}. | 1098 | from @samp{!:1*}. |
| @@ -1008,6 +1262,11 @@ Since it keeps the cursor up where the command was invoked. | |||
| 1008 | 1262 | ||
| 1009 | @printindex fn | 1263 | @printindex fn |
| 1010 | 1264 | ||
| 1265 | @node Command Index | ||
| 1266 | @unnumbered Command Index | ||
| 1267 | |||
| 1268 | @printindex cm | ||
| 1269 | |||
| 1011 | @node Key Index | 1270 | @node Key Index |
| 1012 | @unnumbered Key Index | 1271 | @unnumbered Key Index |
| 1013 | 1272 | ||