csh history search

Polytropon freebsd at edvax.de
Mon Oct 24 17:24:06 UTC 2016

On Mon, 24 Oct 2016 11:39:59 -0400, Ernie Luzar wrote:
> Hello List;
> Reading this section "History substitution" in csh(1) seems to indicate 
> I can pull up a previous command from the history list.
> Lets say that a while back I issued this command
> ping -c 4 hometown.jones.domain.com
> Now I would like to retrieve that domain name from the history list.
> On the command line I enter  !?jon
> The complete ping command is retrieved and automatically executed.
> I don't want the found command automatically executed, I just want the 
> found command inserted to the command line being visible so I can 
> manually modify it before choosing to execute it.
> I could not find any info in csh(1) about auto exec or how to stop it. 
> Hoping someone who uses this csh function could help me out.

Start by typing the first few characters of the command, e. g.

	% ping_

then use the up arrow to browse through all commands starting
with "ping"; if "ping -c 4 hometown.jones.domain.com" was the
last ping command executed, it will show up immediately, and
you can start editing the command (Ctrl+right to word-jump,
or End Ctrl+W to erase the last word, just as you prefer).

The more "words" (or characters) you have at the beginning
of the command line, the more "precise" the search results
will be ("ping" is more "precise" than "p").

For more sophisticated searching, you could write a simple
wrapper around "history | grep" (including a grep -v to remove
the search itself from the search result); this topic has been
discussed on the list, and you can surely find working code
in the archive.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list