##// END OF EJS Templates
Various corrections to interactive reference docs; removed information on shadow history.
Thomas Kluyver -
Show More
@@ -604,7 +604,7 b' Session logging and restoring'
604 -----------------------------
604 -----------------------------
605
605
606 You can log all input from a session either by starting IPython with the
606 You can log all input from a session either by starting IPython with the
607 command line switche ``logfile=foo.py`` (see :ref:`here <command_line_options>`)
607 command line switch ``--logfile=foo.py`` (see :ref:`here <command_line_options>`)
608 or by activating the logging at any moment with the magic function %logstart.
608 or by activating the logging at any moment with the magic function %logstart.
609
609
610 Log files can later be reloaded by running them as scripts and IPython
610 Log files can later be reloaded by running them as scripts and IPython
@@ -648,7 +648,7 b' System shell access'
648
648
649 Any input line beginning with a ! character is passed verbatim (minus
649 Any input line beginning with a ! character is passed verbatim (minus
650 the !, of course) to the underlying operating system. For example,
650 the !, of course) to the underlying operating system. For example,
651 typing !ls will run 'ls' in the current directory.
651 typing ``!ls`` will run 'ls' in the current directory.
652
652
653 Manual capture of command output
653 Manual capture of command output
654 --------------------------------
654 --------------------------------
@@ -702,9 +702,9 b' The %alias magic function and the alias option in the ipythonrc'
702 configuration file allow you to define magic functions which are in fact
702 configuration file allow you to define magic functions which are in fact
703 system shell commands. These aliases can have parameters.
703 system shell commands. These aliases can have parameters.
704
704
705 '%alias alias_name cmd' defines 'alias_name' as an alias for 'cmd'
705 ``%alias alias_name cmd`` defines 'alias_name' as an alias for 'cmd'
706
706
707 Then, typing '%alias_name params' will execute the system command 'cmd
707 Then, typing ``%alias_name params`` will execute the system command 'cmd
708 params' (from your underlying operating system).
708 params' (from your underlying operating system).
709
709
710 You can also define aliases with parameters using %s specifiers (one per
710 You can also define aliases with parameters using %s specifiers (one per
@@ -722,9 +722,8 b' replaced by a positional parameter to the call to %parts::'
722 If called with no parameters, %alias prints the table of currently
722 If called with no parameters, %alias prints the table of currently
723 defined aliases.
723 defined aliases.
724
724
725 The %rehash/rehashx magics allow you to load your entire $PATH as
725 The %rehashx magic allows you to load your entire $PATH as
726 ipython aliases. See their respective docstrings (or sec. 6.2
726 ipython aliases. See its docstring for further details.
727 <#sec:magic> for further details).
728
727
729
728
730 .. _dreload:
729 .. _dreload:
@@ -765,15 +764,14 b' addition to the %rep magic command that brings a history entry'
765 up for editing on the next command line.
764 up for editing on the next command line.
766
765
767 The following GLOBAL variables always exist (so don't overwrite them!):
766 The following GLOBAL variables always exist (so don't overwrite them!):
768 _i: stores previous input. _ii: next previous. _iii: next-next previous.
767
769 _ih : a list of all input _ih[n] is the input from line n and this list
768 * _i, _ii, _iii: store previous, next previous and next-next previous inputs.
770 is aliased to the global variable In. If you overwrite In with a
769 * In, _ih : a list of all inputs; _ih[n] is the input from line n. If you
771 variable of your own, you can remake the assignment to the internal list
770 overwrite In with a variable of your own, you can remake the assignment to the
772 with a simple 'In=_ih'.
771 internal list with a simple ``In=_ih``.
773
772
774 Additionally, global variables named _i<n> are dynamically created (<n>
773 Additionally, global variables named _i<n> are dynamically created (<n>
775 being the prompt counter), such that
774 being the prompt counter), so ``_i<n> == _ih[<n>] == In[<n>]``.
776 _i<n> == _ih[<n>] == In[<n>].
777
775
778 For example, what you typed at prompt 14 is available as _i14, _ih[14]
776 For example, what you typed at prompt 14 is available as _i14, _ih[14]
779 and In[14].
777 and In[14].
@@ -781,55 +779,23 b' and In[14].'
781 This allows you to easily cut and paste multi line interactive prompts
779 This allows you to easily cut and paste multi line interactive prompts
782 by printing them out: they print like a clean string, without prompt
780 by printing them out: they print like a clean string, without prompt
783 characters. You can also manipulate them like regular variables (they
781 characters. You can also manipulate them like regular variables (they
784 are strings), modify or exec them (typing 'exec _i9' will re-execute the
782 are strings), modify or exec them (typing ``exec _i9`` will re-execute the
785 contents of input prompt 9, 'exec In[9:14]+In[18]' will re-execute lines
783 contents of input prompt 9.
786 9 through 13 and line 18).
787
784
788 You can also re-execute multiple lines of input easily by using the
785 You can also re-execute multiple lines of input easily by using the
789 magic %macro function (which automates the process and allows
786 magic %macro function (which automates the process and allows
790 re-execution without having to type 'exec' every time). The macro system
787 re-execution without having to type 'exec' every time). The macro system
791 also allows you to re-execute previous lines which include magic
788 also allows you to re-execute previous lines which include magic
792 function calls (which require special processing). Type %macro? or see
789 function calls (which require special processing). Type %macro? for more details
793 sec. 6.2 <#sec:magic> for more details on the macro system.
790 on the macro system.
794
791
795 A history function %hist allows you to see any part of your input
792 A history function %hist allows you to see any part of your input
796 history by printing a range of the _i variables.
793 history by printing a range of the _i variables.
797
794
798 You can also search ('grep') through your history by typing
795 You can also search ('grep') through your history by typing
799 '%hist -g somestring'. This also searches through the so called *shadow history*,
796 ``%hist -g somestring``. This is handy for searching for URLs, IP addresses,
800 which remembers all the commands (apart from multiline code blocks)
797 etc. You can bring history entries listed by '%hist -g' up for editing
801 you have ever entered. Handy for searching for svn/bzr URL's, IP adrresses
798 with the %recall command, or run them immediately with %rerun.
802 etc. You can bring shadow history entries listed by '%hist -g' up for editing
803 (or re-execution by just pressing ENTER) with %rep command. Shadow history
804 entries are not available as _iNUMBER variables, and they are identified by
805 the '0' prefix in %hist -g output. That is, history entry 12 is a normal
806 history entry, but 0231 is a shadow history entry.
807
808 Shadow history was added because the readline history is inherently very
809 unsafe - if you have multiple IPython sessions open, the last session
810 to close will overwrite the history of previountly closed session. Likewise,
811 if a crash occurs, history is never saved, whereas shadow history entries
812 are added after entering every command (so a command executed
813 in another IPython session is immediately available in other IPython
814 sessions that are open).
815
816 To conserve space, a command can exist in shadow history only once - it doesn't
817 make sense to store a common line like "cd .." a thousand times. The idea is
818 mainly to provide a reliable place where valuable, hard-to-remember commands can
819 always be retrieved, as opposed to providing an exact sequence of commands
820 you have entered in actual order.
821
822 Because shadow history has all the commands you have ever executed,
823 time taken by %hist -g will increase oven time. If it ever starts to take
824 too long (or it ends up containing sensitive information like passwords),
825 clear the shadow history by `%clear shadow_nuke`.
826
827 Time taken to add entries to shadow history should be negligible, but
828 in any case, if you start noticing performance degradation after using
829 IPython for a long time (or running a script that floods the shadow history!),
830 you can 'compress' the shadow history by executing
831 `%clear shadow_compress`. In practice, this should never be necessary
832 in normal use.
833
799
834 .. _output_caching:
800 .. _output_caching:
835
801
@@ -874,7 +840,7 b' Directory history'
874
840
875 Your history of visited directories is kept in the global list _dh, and
841 Your history of visited directories is kept in the global list _dh, and
876 the magic %cd command can be used to go to any entry in that list. The
842 the magic %cd command can be used to go to any entry in that list. The
877 %dhist command allows you to view this history. Do ``cd -<TAB`` to
843 %dhist command allows you to view this history. Do ``cd -<TAB>`` to
878 conveniently view the directory history.
844 conveniently view the directory history.
879
845
880
846
General Comments 0
You need to be logged in to leave comments. Login now