minor vi/vim qstn

Polytropon freebsd at edvax.de
Thu Sep 26 20:05:15 UTC 2013


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, ...


More information about the freebsd-questions mailing list