Re: minor vi/vim qstn

2013-09-26 Thread Karl Vogel
>> On Thu, Sep 26, 2013 at 10:05:06PM +0200, Polytropon wrote:
P> Depending on _typical_ terminal heights (100 lines?), this [history
P> setting] seems to be a bit high.  But I assume zsh handles the "h"
P> alias similarly to the csh, where an alias is defined (system-wide in
P> /etc/csh.cshrc or per user in ~/.cshrc).

   The "fc" builtin can be helpful here.  I like to see my recent history
   without numbering, so I can highlight/rerun/store any useful subset of
   commands:

# history without command numbers, look for optional pattern.
h () {
case "$#" in
0)  fc -ln 1 | less +G ;;
*)  fc -ln 1 | grep ${1+"$@"} ;;
esac
}

   If I dork up my history beyond belief, edit and reload the whole thing:

histedit () {
x="$HOME/.histedit"
fc -W $x && vi $x && fc -R $x && rm $x
}

>> In a previous message:
P> % history 20 | awk 'BEGIN {cmds=20} ... | grep -v "history"

   You can avoid some history pollution with these settings, at least in
   ZSH version 4.3.10:

setopt histignoredups   # don't store duplicate lines in command history
setopt histnostore  # don't store history commands in history

   Other settings I've found useful:

setopt autocd   # go to a directory if first word on command line
# is not a command but is a directory
setopt autoresume   # single-word commands may resume a suspended job
setopt cdablevars   # allows cd'ing to a parameter
setopt correct  # try to correct the spelling of commands
setopt csh_junkie_loops # allow short form of loops: list; end
setopt extendedglob # allow # and ^ to be used for filename generation
setopt extended_history # format: ::
setopt globdots # don't require leading . in filename to be matched
setopt ignoreeof# don't logout using Control-D
setopt longlistjobs # list jobs in long format by default
setopt markdirs # append trailing / to dirnames
setopt menucomplete # cycle through completions when ambiguous
setopt numeric_globsort # sort numeric filenames numerically
setopt noclobber# don't overwrite existing files
setopt notify   # tell me when a job finishes
setopt rcquotes # '' = single quote in single-quoted strings
unsetopt bgnice # don't run background jobs at lower priority

-- 
Karl Vogel  I don't speak for the USAF or my company
vogelke at pobox dot com   http://www.pobox.com/~vogelke

Teenage girl creates sustainable, renewable algae biofuel under her bed
--Extreme Tech headline, 19 March 2013
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-26 Thread Polytropon
On Thu, 26 Sep 2013 13:58:19 -0700, Gary Kline wrote:
> Organization: Thought Unlimited.  Public service Unix since 1986.
> Of_Interest: With 27 years  of service  to the  Unix  community.
> 
> On Thu, Sep 26, 2013 at 10:05:06PM +0200, Polytropon wrote:
> > 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
> 
>   
>   I'remember seeing this a long time ago.  in my ~/.zshrc I've got
>   iit in all CAPS. 
> 
> 
> 
> HISTFILE=~/.zhistory 
> SAVEHIST='5000'
> HISTSIZE=1000
> 
> 
>   got to google this; been tooo long since I glanced  at the code!

That's probably correct, it reflects the "sh-like aspects"
of code (as I said, csh is a terrible scripting shell, and
this is also true regarding its configuration files). So
those entries look correct.

I'm not a zsh user, so I can't say this for sure. I'm heavily
infected with csh already. ;-)



On Thu, 26 Sep 2013 14:15:17 -0700, Gary Kline wrote:
>   FWIW, I just tried:
> 
>   alias -- h='history 50'
> 
> 
>   works as it ought; last time I tried, the history quit 
>   after ~10.  [?]

The reason might be that the history, at this point in time,
did only contain 10 entries. I don't know how the content
of ~/.zhistory behaves if more than one shell is running
for a given user...

The Z shell is very customizable and can automate routine
tasks (regarding the shell dialog) in a pleasant manner.
If you want the last 10 commands to be displayed before the
shell prompt appears, try something like this in ~/.zshrc:

function precmd {
history 10 | awk 'BEGIN {histcmds=10} { printf("\t%2d\t%s\n", 
-(histcmds-i), $0); i++ }' | grep -v "histcmds"
}

Not tested, but it seems to be much easier as zsh simply
defines a function "precmd" and doesn't require the user
to fight with quotes, doublequotes and escaping as csh
successfully does. :-)





-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-26 Thread Gary Kline
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 27 years  of service  to the  Unix  community.

On Thu, Sep 26, 2013 at 10:05:06PM +0200, Polytropon wrote:
> 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.
> 
FWIW, I just tried:

alias -- h='history 50'


works as it ought; last time I tried, the history quit 
after ~10.  [?]


> 
> > (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, ...
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
 Twenty-seven years of service to the Unix community.
http://www.thought.org/HOPE


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-26 Thread Gary Kline
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 27 years  of service  to the  Unix  community.

On Thu, Sep 26, 2013 at 10:05:06PM +0200, Polytropon wrote:
> 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


I'remember seeing this a long time ago.  in my ~/.zshrc I've got
iit in all CAPS. 



HISTFILE=~/.zhistory 
SAVEHIST='5000'
HISTSIZE=1000


got to google this; been tooo long since I glanced  at the code!


> 
> 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 ..."). :-)
> 
> 
I'll be typing for 10 years before I'v saved the keystrokes ive
spent here

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

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
 Twenty-seven years of service to the Unix community.
http://www.thought.org/HOPE


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-26 Thread Polytropon
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, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-26 Thread Gary Kline
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 27 years  of service  to the  Unix  community.

On Thu, Sep 26, 2013 at 03:26:29PM +0200, Polytropon wrote:
> 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. :-)

Oh, n!  ive got to go hide my head in the sand for 25
years...   { it's so emmbarrassing!!}

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


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.  

I use as many zsh-isms as saves keystrokes.  thanks for that 
awk shortcut; ill use ir... :_)


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


good grief, man.  I just got up from a nap... can you re-word that? 
no, kidding.  I get it.  


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



> 
>   % 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.  
> 
> > 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, ...
> ___
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
 Twenty-seven years of service to the Unix community.
http://www.thought.org/HOPE


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-26 Thread Polytropon
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, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-25 Thread Gary Kline
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 27 years  of service  to the  Unix  community.

On Thu, Sep 26, 2013 at 03:06:00AM +0200, Polytropon wrote:
> On Wed, 25 Sep 2013 17:21:04 -0700, Gary Kline wrote:
> > Organization: Thought Unlimited.  Public service Unix since 1986.
> > Of_Interest: With 27 years  of service  to the  Unix  community.
> > 
> > On Thu, Sep 26, 2013 at 12:23:27AM +0200, Polytropon wrote:
> > > On Wed, 25 Sep 2013 14:27:41 -0700, Gary Kline wrote:
> > > > am I misremembering this feature, or didnt vi have a syntax 
> > > > where
> > > > you typed something like:
> > > > 
> > > > % vi[#] or % vi [-2]  [or vi [-N]
> > > > 
> > > > to repeat the last or the second from last  command?  with my
> > > > shoulder sore bloody sore I need to save every key stroke.  
> > > 
> > > To repeat the last command, "." can be used.
> > > 
> > > The vi editor (and probably vim and gvim) supports
> > > according to "man vi":
> > > 
> > >[Vi]i[sual][!] [+cmd] [file]
> > >   Vi mode only.  Edit a new file.
> > > 
> > > Is this what you're searching for?
> > 
> > 
> > I THOGoHT it was "!", but lookit:
> > 
> > 
> > pts/14 17:11  [5010] vi sent
> > pts/14 17:11  [5011] vi!
> > zsh: command not found: vi!
> > pts/14 17:12  [5012]
> > 
> > ...  this is vi == vim.  
> > 
> > AHA:: found it.  it's [bang]
> > 
> > 
> > pts/14 17:17  [5016] vi sent
> > pts/14 17:17  [5017] !v
> > 
> > 
> > I'll tell ya, if vi disappeared , I'd end it all!
> 
> Ah, I see - you've been refering to repeating a _shell_
> command (so the question was regarding the shell, which
> in your case is Z shell).
> 
> You can probably use (like in the C shell) the arrow keys
> to browse the command history. Similarly, you can use the
> "!" command refering to the command number obtained
> by the "history" command. There's a handy alias defined
> globally for the C shell: "h" which means "history 25"
> (lists the last 25 commands), handy in regards of saving
> keystrokes. :-)
> 
> I assume the zsh is also capable of "filtered history":
> For example, you enter "vi s" and use the up and down
> arrow keys to browse all commands that have been entered
> starting with "vi s" (for example "vi sent", "vi stuff"
> and so on). If the system's csh can do this, zsh should
> also provide this useful feature.
> 
> And as your prompt "pts/14 17:12  [5012]" suggests,
> the command number is being shown. If this information
> is the same as the command number in the history, entering
> "!5010" would execute the 2nd from last command.
> 
> To repeat the last command, whatever it has been, "!!"
> can be used. Again, this works in csh, so I can't predict
> if it will work in zsh too, but I _assume_ it does.
> 
dunno how you know im using the zsh, but yup.  with the bang stuff
if you do a 

% !-3

you go back three vi cmds.  !-N, N cmds. 

thankfully there are shortcuts!

gary

ps: zsh is sort of a ksh clone; I remember porting the zsh onto
my 286 in 1989.  got a lot of csh-isms :)


-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
 Twenty-seven years of service to the Unix community.
http://www.thought.org/HOPE


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-25 Thread Polytropon
On Wed, 25 Sep 2013 17:21:04 -0700, Gary Kline wrote:
> Organization: Thought Unlimited.  Public service Unix since 1986.
> Of_Interest: With 27 years  of service  to the  Unix  community.
> 
> On Thu, Sep 26, 2013 at 12:23:27AM +0200, Polytropon wrote:
> > On Wed, 25 Sep 2013 14:27:41 -0700, Gary Kline wrote:
> > >   am I misremembering this feature, or didnt vi have a syntax where
> > >   you typed something like:
> > > 
> > >   % vi[#] or % vi [-2]  [or vi [-N]
> > >   
> > >   to repeat the last or the second from last  command?  with my
> > >   shoulder sore bloody sore I need to save every key stroke.  
> > 
> > To repeat the last command, "." can be used.
> > 
> > The vi editor (and probably vim and gvim) supports
> > according to "man vi":
> > 
> >[Vi]i[sual][!] [+cmd] [file]
> >   Vi mode only.  Edit a new file.
> > 
> > Is this what you're searching for?
> 
> 
>   I THOGoHT it was "!", but lookit:
> 
> 
> pts/14 17:11  [5010] vi sent
> pts/14 17:11  [5011] vi!
> zsh: command not found: vi!
> pts/14 17:12  [5012]
> 
> ...  this is vi == vim.  
> 
>   AHA:: found it.  it's [bang]
> 
> 
> pts/14 17:17  [5016] vi sent
> pts/14 17:17  [5017] !v
> 
> 
>   I'll tell ya, if vi disappeared , I'd end it all!

Ah, I see - you've been refering to repeating a _shell_
command (so the question was regarding the shell, which
in your case is Z shell).

You can probably use (like in the C shell) the arrow keys
to browse the command history. Similarly, you can use the
"!" command refering to the command number obtained
by the "history" command. There's a handy alias defined
globally for the C shell: "h" which means "history 25"
(lists the last 25 commands), handy in regards of saving
keystrokes. :-)

I assume the zsh is also capable of "filtered history":
For example, you enter "vi s" and use the up and down
arrow keys to browse all commands that have been entered
starting with "vi s" (for example "vi sent", "vi stuff"
and so on). If the system's csh can do this, zsh should
also provide this useful feature.

And as your prompt "pts/14 17:12  [5012]" suggests,
the command number is being shown. If this information
is the same as the command number in the history, entering
"!5010" would execute the 2nd from last command.

To repeat the last command, whatever it has been, "!!"
can be used. Again, this works in csh, so I can't predict
if it will work in zsh too, but I _assume_ it does.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-25 Thread Gary Kline
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 27 years  of service  to the  Unix  community.

On Thu, Sep 26, 2013 at 12:23:27AM +0200, Polytropon wrote:
> On Wed, 25 Sep 2013 14:27:41 -0700, Gary Kline wrote:
> > am I misremembering this feature, or didnt vi have a syntax where
> > you typed something like:
> > 
> > % vi[#] or % vi [-2]  [or vi [-N]
> > 
> > to repeat the last or the second from last  command?  with my
> > shoulder sore bloody sore I need to save every key stroke.  
> 
> To repeat the last command, "." can be used.
> 
> The vi editor (and probably vim and gvim) supports
> according to "man vi":
> 
>[Vi]i[sual][!] [+cmd] [file]
>   Vi mode only.  Edit a new file.
> 
> Is this what you're searching for?


I THOGoHT it was "!", but lookit:


pts/14 17:11  [5010] vi sent
pts/14 17:11  [5011] vi!
zsh: command not found: vi!
pts/14 17:12  [5012]

...  this is vi == vim.  

AHA:: found it.  it's [bang]


pts/14 17:17  [5016] vi sent
pts/14 17:17  [5017] !v


I'll tell ya, if vi disappeared , I'd end it all!

tx.

gary






> Or do you refer to command lines where "@:" would repeat the

-N T- 34/41: P> last command (started with ":")?
> 
> -- 
> Polytropon
> Magdeburg, Germany
> Happy FreeBSD user since 4.0
> Andra moi ennepe, Mousa, ...

-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
 Twenty-seven years of service to the Unix community.
http://www.thought.org/HOPE


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


Re: minor vi/vim qstn

2013-09-25 Thread Polytropon
On Wed, 25 Sep 2013 14:27:41 -0700, Gary Kline wrote:
>   am I misremembering this feature, or didnt vi have a syntax where
>   you typed something like:
> 
>   % vi[#] or % vi [-2]  [or vi [-N]
>   
>   to repeat the last or the second from last  command?  with my
>   shoulder sore bloody sore I need to save every key stroke.  

To repeat the last command, "." can be used.

The vi editor (and probably vim and gvim) supports
according to "man vi":

   [Vi]i[sual][!] [+cmd] [file]
  Vi mode only.  Edit a new file.

Is this what you're searching for?

Or do you refer to command lines where "@:" would repeat the
last command (started with ":")?

-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"


minor vi/vim qstn

2013-09-25 Thread Gary Kline
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 27 years  of service  to the  Unix  community.

folks,

am I misremembering this feature, or didnt vi have a syntax where
you typed something like:

% vi[#] or % vi [-2]  [or vi [-N]

to repeat the last or the second from last  command?  with my
shoulder sore bloody sore I need to save every key stroke.  

TIA, y'all,

gary



-- 
 Gary Kline  kl...@thought.org  http://www.thought.org  Public Service Unix
 Twenty-seven years of service to the Unix community.
http://www.thought.org/HOPE


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"