zsh-users
 help / color / mirror / code / Atom feed
* searching upwards from cwd
@ 2006-06-19  8:15 Dominik Vogt
  2006-06-19  9:13 ` Marc Chantreux
  2006-06-19 16:11 ` Bart Schaefer
  0 siblings, 2 replies; 7+ messages in thread
From: Dominik Vogt @ 2006-06-19  8:15 UTC (permalink / raw)
  To: zsh-users; +Cc: dominik.vogt

The EQUALS option is very handy, and I'd like to have something similary,
but with a different search path.  My working directory, is structured like this:

  work/
    adresses.txt
    cvs/
      projectx/
        src/
          foo/
      projecty/
        ...

I'd like to be able to open addresses.txt in a single command without knowing
about the working directory.  At the moment, the command depends on cwd:

  work/  =>  less addresses.txt
  work/cvs/  =>  less ../addresses.txt
  work/cvs/projectx/  =>  less ../../addresses.txt
  work/cvs/projectx/src/  =>  less ../../../addresses.txt

It would be very helpful to have an alternative syntax similar to
'**/<filename>' and '=<filename>' that looks upwards in the path.  Maybe

  **/adresses.txt   =>  look in all subdirs
  =addresses.txt => look in the PATH
  .=addresses.txt => successively look in ., .., ../.., ../../.. and so on
  **.=addresses.txt => works like .=, and if that fails works like **/

(or whatever the syntax would be).

I'd be happy to have it as a zsh function, but I think it could be done
much more efficient in the source code.

Ciao

Dominik ^_^  ^_^

P.S.:  Please CC me for fast replies.
-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: searching upwards from cwd
  2006-06-19  8:15 searching upwards from cwd Dominik Vogt
@ 2006-06-19  9:13 ` Marc Chantreux
  2006-06-19 21:03   ` Dominik Vogt
  2006-06-19 16:11 ` Bart Schaefer
  1 sibling, 1 reply; 7+ messages in thread
From: Marc Chantreux @ 2006-06-19  9:13 UTC (permalink / raw)
  To: Dominik Vogt; +Cc: zsh-users

Hi Dominik,

le 19/06/2006,
Dominik Vogt nous écrivait :
> 
> I'd like to be able to open addresses.txt in a single command without knowing
> about the working directory.  At the moment, the command depends on cwd:
> 
>   work/  =>  less addresses.txt
>   work/cvs/  =>  less ../addresses.txt
>   work/cvs/projectx/  =>  less ../../addresses.txt
>   work/cvs/projectx/src/  =>  less ../../../addresses.txt

is this enought ? 

from () {
        local base=${PWD%/$1/*}/$1
        shift
        print -l $base/${~^*}
}

less $( from works '**/adresses.txt' )

regards


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: searching upwards from cwd
  2006-06-19  8:15 searching upwards from cwd Dominik Vogt
  2006-06-19  9:13 ` Marc Chantreux
@ 2006-06-19 16:11 ` Bart Schaefer
  2006-06-20  5:32   ` Sami Samhuri
  1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2006-06-19 16:11 UTC (permalink / raw)
  To: zsh-users

On Jun 19, 10:15am, Dominik Vogt wrote:
}
} It would be very helpful to have an alternative syntax similar to
} '**/<filename>' and '=<filename>' that looks upwards in the path.

setopt extendeglob
less (../)#addresses.txt


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: searching upwards from cwd
  2006-06-19  9:13 ` Marc Chantreux
@ 2006-06-19 21:03   ` Dominik Vogt
  2006-06-20 18:28     ` Dominik Vogt
  0 siblings, 1 reply; 7+ messages in thread
From: Dominik Vogt @ 2006-06-19 21:03 UTC (permalink / raw)
  To: zsh-users; +Cc: Dominik Vogt

[-- Attachment #1: Type: text/plain, Size: 908 bytes --]

On Mon, Jun 19, 2006 at 11:13:28AM +0200, Marc Chantreux wrote:
> Hi Dominik,
> 
> le 19/06/2006,
> Dominik Vogt nous écrivait :
> > 
> > I'd like to be able to open addresses.txt in a single command without knowing
> > about the working directory.  At the moment, the command depends on cwd:
> > 
> >   work/  =>  less addresses.txt
> >   work/cvs/  =>  less ../addresses.txt
> >   work/cvs/projectx/  =>  less ../../addresses.txt
> >   work/cvs/projectx/src/  =>  less ../../../addresses.txt
> 
> is this enought ? 
> 
> from () {
>         local base=${PWD%/$1/*}/$1
>         shift
>         print -l $base/${~^*}
> }
> 
> less $( from works '**/adresses.txt' )

Ah, that's not quite what I'm looking for.  It's too much to type
- I could as well try an increasing numer of '../' components and
hit TAB every time.

Dominik ^_^  ^_^

 --
Dominik Vogt, dominik.vogt@gmx.de

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: searching upwards from cwd
  2006-06-19 16:11 ` Bart Schaefer
@ 2006-06-20  5:32   ` Sami Samhuri
  0 siblings, 0 replies; 7+ messages in thread
From: Sami Samhuri @ 2006-06-20  5:32 UTC (permalink / raw)
  To: zsh-users


On 19-Jun-06, at 6:11 PM, Bart Schaefer wrote:

> On Jun 19, 10:15am, Dominik Vogt wrote:
> }
> } It would be very helpful to have an alternative syntax similar to
> } '**/<filename>' and '=<filename>' that looks upwards in the path.
>
> setopt extendeglob
> less (../)#addresses.txt
>

How incredibly useful. zsh continues to astound me every time I read  
this list. Pretty much every time someone asks for something, the zsh  
devs have already implemented it. Any zsh devs reading this, thank  
you for making zsh the best shell around, bar none. Keep up the  
excellent work!

Sami


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: searching upwards from cwd
  2006-06-19 21:03   ` Dominik Vogt
@ 2006-06-20 18:28     ` Dominik Vogt
  2006-06-21  1:53       ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Dominik Vogt @ 2006-06-20 18:28 UTC (permalink / raw)
  To: zsh-users; +Cc: Dominik Vogt

[-- Attachment #1: Type: text/plain, Size: 1180 bytes --]

On Mon, Jun 19, 2006 at 11:03:57PM +0200, Dominik Vogt wrote:
> On Mon, Jun 19, 2006 at 11:13:28AM +0200, Marc Chantreux wrote:
> > le 19/06/2006,
> > Dominik Vogt nous écrivait :
> > > 
> > > I'd like to be able to open addresses.txt in a single command without knowing
> > > about the working directory.  At the moment, the command depends on cwd:
> > > 
> > >   work/  =>  less addresses.txt
> > >   work/cvs/  =>  less ../addresses.txt
> > >   work/cvs/projectx/  =>  less ../../addresses.txt
> > >   work/cvs/projectx/src/  =>  less ../../../addresses.txt
> > 
> > is this enought ? 
> > 
> > from () {
> >         local base=${PWD%/$1/*}/$1
> >         shift
> >         print -l $base/${~^*}
> > }
> > 
> > less $( from works '**/adresses.txt' )
> 
> Ah, that's not quite what I'm looking for.  It's too much to type
> - I could as well try an increasing numer of '../' components and
> hit TAB every time.

Hm, this is close:

  less (../)#adr*

But is there any way to prevent the globbing pattern is expanded
to multiple words?  I just want the first/shortest match.

Ciao

Dominik ^_^  ^_^

 --
Dominik Vogt, dominik.vogt@gmx.de

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: searching upwards from cwd
  2006-06-20 18:28     ` Dominik Vogt
@ 2006-06-21  1:53       ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2006-06-21  1:53 UTC (permalink / raw)
  To: zsh-users

On Jun 20,  8:28pm, Dominik Vogt wrote:
}
}   less (../)#adr*
} 
} But is there any way to prevent the globbing pattern is expanded
} to multiple words?  I just want the first/shortest match.

Try

    less (../)#adr*(Odon[1])


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-06-21  1:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-19  8:15 searching upwards from cwd Dominik Vogt
2006-06-19  9:13 ` Marc Chantreux
2006-06-19 21:03   ` Dominik Vogt
2006-06-20 18:28     ` Dominik Vogt
2006-06-21  1:53       ` Bart Schaefer
2006-06-19 16:11 ` Bart Schaefer
2006-06-20  5:32   ` Sami Samhuri

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).