From owner-freebsd-questions@FreeBSD.ORG Thu Sep 26 20:05:15 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 95022FA7 for ; Thu, 26 Sep 2013 20:05:15 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 57CED2797 for ; Thu, 26 Sep 2013 20:05:15 +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 mx02.qsc.de (Postfix) with ESMTPS id 7E2B427A7F; Thu, 26 Sep 2013 22:05:13 +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 r8QK56GA003539; Thu, 26 Sep 2013 22:05:06 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Thu, 26 Sep 2013 22:05:06 +0200 From: Polytropon To: Gary Kline Subject: Re: minor vi/vim qstn Message-Id: <20130926220506.d9c11563.freebsd@edvax.de> In-Reply-To: <20130926195132.GA24184@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> <20130926152629.89e6dd72.freebsd@edvax.de> <20130926195132.GA24184@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 20:05:15 -0000 On Thu, 26 Sep 2013 12:51:32 -0700, Gary Kline wrote: > my zsh does a default to 10 or so history with just > > % h > > I was trying to remember how to set it to ,, say, 100. Depending on _typical_ terminal heights (100 lines?), this seems to be a bit high. But I assume zsh handles the "h" alias similarly to the csh, where an alias is defined (system-wide in /etc/csh.cshrc or per user in ~/.cshrc). Look for ~/.zshrc (if I remember correctly): alias h 'history 25' and change it accordingly. An interactive change is also possible (but will only be kept for the current session). I also assume the zsh has some settings on how many commands should be kept in history. The system's /etc/csh.cshrc provides the csh's equivalent: set history = 100 set savehist = 100 Probably zsh has something similar. > (for as many centuries as ive been using vi [nvi], there are > *still* things I never had need to learn. so it turns out that > a lot of theses "clever" sh scripts are over my head .... it > takes mins -> hours to figure out. You notice that you're saying that to a programmer whose shell scripts are usually overcomplicated, dull, and could use lots of optimization? ;-) > > % 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... > > > I have grep -v aliased to grv. If you're using that alias inside another alias, zsh (if it acts like csh) will expand it properly. Using such an alias in a "one-time entry" (as I'd consider an addition to a configuration file) still doesn't sound optimal regarding readability and maintainability. As if we would ever maintain our "naturally grown" (over centuries) configuration files... ;-) Still I think turning the example into a shell alias ("h20") or assigning it (with 20 -> 10) to the "precmd" alias could not be trivial, at least regarding the C shell, because lots of quoting and escaping would be needed; maybe zsh does not behave like a madman in this regards ("unmatched this, unmatched that, sytax error, cannot expand, missing argument, blah ..."). :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...