David Lee | 23 May 12:10
Picon

Autocomplete for umount with space

Hi ZSH users,

Autocompletion for umount lists mount points clipped at the first space. For example, if I have
"/Volumes/Media Drive" and "/Volumes/Media Disk", autocomplete for amount will only list a single "/Volumes/Media".

Is there a fix or workaround for this?

--David
Han Pingtian | 23 May 08:18
Picon

globbing in assignment

Hello,

I just notice filename globbing doesn't occur in my script, like 

v=*

but it works in the interactive shell. Althoug I can make it work
by "setop glob_assign" or use "v=(*)", but it looks like the behavior's
diversity is a little strange.

Any thoughts?

Thanks.

Ronald Fischer | 22 May 09:38
Favicon

Re: zsh-users Digest 21 May 2012 17:55:56 -0000 Issue 1820

> > echo a/f/b/b/x<TAB>
> > Doesn't help here, for two reason:
> > (1) At least in my version of zsh (4.3.12), this would not expand the
> > interim directories (f,b,b).

> Does your zsh configuration include installing the completion system
> (the "compinit" command)?

Doesn't look like:

(1;0) /cygdrive/c> type compinit
compinit not found

However I think I should have the completion system installed:

(1;1) /cygdrive/c> zmodload
zsh/compctl
zsh/complete
zsh/main
zsh/zle

Is there an additional module that I need here?

> > (2) Even if I could do TAB completion on directories within the path,
> > this is not what I'm looking for, because it is still cumbersome to
> > type.

> You might want to look at named directories

Thank you for this suggestion. I'll have a look at it!
(Continue reading)

Danek Duvall | 21 May 23:40

completion oddity

If I have a completion function like this:

    _k () { _arguments --r1-word --r2-word }

and I press TAB at the end of the following commandline:

    % k --r

then I get

    % k --r-word

Another tab beeps and lists the choices, a third tab beeps and chooses
--r1-word, and thereon tabs simply cycle between the two.  That's more or
less expected.

If I define _k instead as

    _k () { _arguments --r1-word --really-r1-word }

then the second tab simply completes --r1-word, which seems wrong to me.

This is all with "zsh -f", with nothing but

    autoload -Uz compinit
    compinit -i
    compdef _k k

run before attempting the completion.

(Continue reading)

zzapper | 19 May 14:51
Picon

Re: Hi, I'm new comer.


> dear Sir/Madam
> 
> I am using zsh and interested in it, so I'd like to learn the one more and
> more. please participate me in your activity.
> 
> thanks
> 
> 
> Takeshi

A good place to start

http://zshwiki.org/

--

-- 
zzapper
http://zzapper.co.uk/ Technical Tips

Ronald Fischer | 18 May 15:16
Favicon

Extracting the 4th word of the first line in a file - is there a more elegant solution?

Within a script, I have need to store the 4th word in the first line of
a file.

Of course this is trivial to implement. However, I'm curious whether
there exists a better way to implement than what I found.

My current solution goes like this:

# $1 is the filename
line=$(head -n 1 $1)
field=${lin[(w)4]}

This is OK, but this needs an auxiliary variable 'line'. 

I could also do it like this:

field=$(head -n 1 $1|cut  -f 4 -d ' ')

No aux variable, but needs a pipe

So I wonder, whether there is a elegant "zsh" solution, which solves
this in a more elegant way?

Ronald
--

-- 
Ronald Fischer <ronaldf <at> eml.cc>
+  If a packet hits a pocket on a socket on a port, 
+  and the bus is interrupted and the interrupt's not caught,
+  then the socket packet pocket has an error to report.
+		(cited after Peter van der Linden)
(Continue reading)

TJ Luoma | 16 May 21:18
Picon
Gravatar

How do I find shortest match?

I have a folder which has a lot of txt files, and in that folder 
are a lot of duplicate files. Most of the duplicates are 
numbered like this:

10-6- Make a universal 10-6-7 Snow Leopard installer-1.txt
10-6- Make a universal 10-6-7 Snow Leopard installer-2.txt
10-6- Make a universal 10-6-7 Snow Leopard installer-3.txt
10-6- Make a universal 10-6-7 Snow Leopard installer-4.txt
10-6- Make a universal 10-6-7 Snow Leopard installer.txt

Not not all of them. For example, I might have another identical 
file named

     todo-make-snowleopardinstaller.txt

What I want to do is go through the entire folder and find all 
duplicate files (files with identical md5sum).

Then I want to keep ONLY the one with the shortest filename.

Here's what I have so far

#!/bin/zsh

DIR=/Users/luomat/Dropbox/txt/

     # to avoid 'arg list too long'
     # note that 'gmd5sum' prints the sum
     # and then two spaces, and then the filename
ALL=$(find $DIR -type f -print0 | xargs -0 gmd5sum)
(Continue reading)

Ronald of Steiermark | 16 May 13:41
Favicon

global aliases substituting *within* a path

I have a set of directory structures like this:

aaa/foo/bar/baz/xxx
bbb/foo/bar/baz/yyy
ccc/foo/bar/baz/zzz
etc.

I'm looking for a way to make typing easier on the command line, in
order to not have to type foo/bar/baz all the time.

Of course I can achieve this by setting a shell variable in my .zshrc:

X=foo/bar/baz

Then I can do for instance

  ls aaa/$X/xxx

Now I recently learned about global aliases, which permit alias
substitution to be done within the command line, and I thought that I
maybe could use this. Here was my (failed) attempt:

alias -g X=foo/bar/baz

# Does NOT work at hoped
ls aaa/X/xxx

X is not substituted, because it is not a word on its own (not
surrounded by spaces).

(Continue reading)

Ronald Fischer | 16 May 13:43
Favicon

global aliases substituting *within* a path

I have a set of directory structures like this:

aaa/foo/bar/baz/xxx
bbb/foo/bar/baz/yyy
ccc/foo/bar/baz/zzz
etc.

I'm looking for a way to make typing easier on the command line, in
order to not have to type foo/bar/baz all the time.

Of course I can achieve this by setting a shell variable in my .zshrc:

X=foo/bar/baz

Then I can do for instance

  ls aaa/$X/xxx

Now I recently learned about global aliases, which permit alias
substitution to be done within the command line, and I thought that I
maybe could use this. Here was my (failed) attempt:

alias -g X=foo/bar/baz

# Does NOT work at hoped
ls aaa/X/xxx

X is not substituted, because it is not a word on its own (not
surrounded by spaces).

(Continue reading)

TJ Luoma | 14 May 21:30
Picon
Gravatar

changing case to Title Case


$ foo="ONE TWO thRee FoUR"
$ print -r -- "${(C)foo}"

will output this:

One Two Three Four

but this:

$ foo="ONE TWO thRee FoUR's"
$ print -r -- "${(C)foo}"

will give this:

One Two Three Four'S

Note the S is capitalized

$ foo="ONE TWO thRee FoUR's.pdf"
$ print -r -- "${(C)foo}"     

will give this:

One Two Three Four'S.Pdf

Note that the P in PDF and the S after ' are capitalized.

Is there any way to avoid that?

(Continue reading)

zzapper | 14 May 17:53
Picon

FNG specify a count

Hi

This is a PHP regexp  /^FLOW_([0-9]{3}).csv$/

I can simulate this in a brute fashion

> ls FLOW_[0-9][0-9][0-9].csv

Is it possible to use a count 3 in ZSH FNG?

--

-- 
zzapper
http://zzapper.co.uk/ Technical Tips


Gmane