From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7761 invoked by alias); 13 Jan 2013 18:54:49 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17556 Received: (qmail 29817 invoked from network); 13 Jan 2013 18:54:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130113105421.ZM5620@torch.brasslantern.com> Date: Sun, 13 Jan 2013 10:54:21 -0800 In-reply-to: Comments: In reply to rahul "vared history not working inside scripts" (Jan 13, 7:55pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: vared history not working inside scripts MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 13, 7:55pm, rahul wrote: } } On the command line, "vared -h" allows me to access history using arrow } keys or Control-R. } Inside a script, nothing happens. Is there some setting I have to make in } scripts. History is normally disabled in scripts. On the "Expansion" summary page in the documentation, under "History Expansion", it is noted that "This is performed only in interactive shells." To enable history in a script, you need to run the "fc -p" command to initialize it. If your script is going to be run as a shell function, it's best to use "fc -a -p" to automatically restore the regular shell history when the function exits. fc -p [ -a ] [ FILENAME [ HISTSIZE [ SAVEHISTSIZE ] ] ] `fc -p' pushes the current history list onto a stack and switches to a new history list. If the -a option is also specified, this history list will be automatically popped when the current function scope is exited, which is a much better solution than creating a trap function to call `fc -P' manually. If no arguments are specified, the history list is left empty, $HISTFILE is unset, and $HISTSIZE & $SAVEHIST are set to their default values. If one argument is given, $HISTFILE is set to that filename, $HISTSIZE & $SAVEHIST are left unchanged, and the history file is read in (if it exists) to initialize the new list. If a second argument is specified, $HISTSIZE & $SAVEHIST are instead set to the single specified numeric value. Finally, if a third argument is specified, $SAVEHIST is set to a separate value from $HISTSIZE. You are free to change these environment values for the new history list however you desire in order to manipulate the new history list. `fc -P' pops the history list back to an older list saved by `fc -p'. ... There's an example of this in Functions/Misc/sticky-note in the sources (usually found at ${^fpath}/sticky-note(N:[1]) after installation).