From owner-freebsd-questions@FreeBSD.ORG Thu Sep 26 13:32:19 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B61FBB88 for ; Thu, 26 Sep 2013 13:32:19 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 785C229F5 for ; Thu, 26 Sep 2013 13:32:19 +0000 (UTC) Received: from r56.edvax.de (port-92-195-74-65.dynamic.qsc.de [92.195.74.65]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 27F2D3D734; Thu, 26 Sep 2013 15:26:36 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id r8QDQTXh002090; Thu, 26 Sep 2013 15:26:29 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Thu, 26 Sep 2013 15:26:29 +0200 From: Polytropon To: Gary Kline Subject: Re: minor vi/vim qstn Message-Id: <20130926152629.89e6dd72.freebsd@edvax.de> In-Reply-To: <20130926024708.GA3908@ethic.thought.org> References: <20130925212741.GA19434@ethic.thought.org> <20130926002327.6502d1b9.freebsd@edvax.de> <20130926002104.GA12932@ethic.thought.org> <20130926030600.8850ddc5.freebsd@edvax.de> <20130926024708.GA3908@ethic.thought.org> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Mailing List X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Sep 2013 13:32:19 -0000 On Wed, 25 Sep 2013 19:47:08 -0700, Gary Kline wrote: > dunno how you know im using the zsh, but yup. This is because of my magical allknowinglyness. :-) You wrote: > > > pts/14 17:11 [5011] vi! > > > zsh: command not found: vi! ^^^ This gave me the impression you're using the Z shell. The C shell says: % vi! vi!: Command not found. And bash says: $ vi! bash: vi!: command not found So the shell that says "zsh" should be the Z shell, or a different shell that's just lying. :-) > with the bang stuff > if you do a > > % !-3 > > you go back three vi cmds. !-N, N cmds. Yes, this also works in C shell. You can use the "h" (or "history") builtin command to get an impression of content of the last commands submitted to the shell. At least in csh, % !-1 equals % !! and repeats the last command. You could use the following command to print the last 20 commands with the relative number (-1, -2, -3 and so on) printed infront of them: % history 20 | awk 'BEGIN {cmds=20} { printf("\t%2d\t%s\n", -(cmds-i), $0); i++ }' It's probably a good idea to define an alias for that, like "h20" (history of last 20 commands). You could also use the zsh's equivalent of the "precmd" alias: It is a command that will be executed prior to displaying the shell prompt, so after you're done with a command, the last commands (maybe shortened to 10, just substitute the two appearances of the "20" to "10") will be displayed before the prompt appears; this will make it easier (and save keystrokes) to check the last commands and maybe repeat one. Downside: The command "pollutes" the list of commands with itself, so it should probably be grepped away. % history 20 | awk 'BEGIN {cmds=20} { printf("\t%2d\t%s\n", -(cmds-i), $0); i++ }' | grep -v "history" It might be good to define a better exclusion pattern than just "history" because that might lead to false-positives. I'd suggest to rename the variables in the awk script to something unique and then grep for those instead... > thankfully there are shortcuts! And shell aliases. :-) > ps: zsh is sort of a ksh clone; I remember porting the zsh onto > my 286 in 1989. got a lot of csh-isms :) The Z shell combines nice interactive features of the C shell (to be correct: the tcsh) and the scripting features of sh and bash. It's considered one of the most powerful shells. So it's a wise move to use it, because it combines "the _good_ things of both worlds" (and not the bad things, as the csh is a terrible scripting shell, just as plain sh is an awful dialog shell). -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...