* directory specific functions and aliases
@ 2015-02-13 15:05 shawn wilson
2015-02-13 15:41 ` Peter Stephenson
0 siblings, 1 reply; 5+ messages in thread
From: shawn wilson @ 2015-02-13 15:05 UTC (permalink / raw)
To: Zsh Users
What would be the best way to make functions that do different things
based on the directory I'm in - kinda like rvm does with rubies? I was
hoping for something cleaner than: case $(pwd) This is mainly because
I want to wrap cvs and rsync differently based on repo (and where
within that repo).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: directory specific functions and aliases
2015-02-13 15:05 directory specific functions and aliases shawn wilson
@ 2015-02-13 15:41 ` Peter Stephenson
2015-02-13 15:52 ` Peter Stephenson
2015-02-13 22:17 ` Mikael Magnusson
0 siblings, 2 replies; 5+ messages in thread
From: Peter Stephenson @ 2015-02-13 15:41 UTC (permalink / raw)
To: Zsh Users
On Fri, 13 Feb 2015 10:05:21 -0500
shawn wilson <ag4ve.us@gmail.com> wrote:
> What would be the best way to make functions that do different things
> based on the directory I'm in - kinda like rvm does with rubies? I was
> hoping for something cleaner than: case $(pwd) This is mainly because
> I want to wrap cvs and rsync differently based on repo (and where
> within that repo).
I use a dot-file in the directory, but you need to be careful with this
--- at least check you own the file before using it for extracting
commands or anything of that kind. You can easily search backward for a
file of the same name in a parent directory if you have EXTENDED_GLOB
set: (../)#.thatdotfilename which will allow you to put in the top level
of a repository.
In particular, I have a local history file that's searched for commands
if they match a certain pattern. Integration with the main history file
sort of works but isn't as seamless as I'd like.
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: directory specific functions and aliases
2015-02-13 15:41 ` Peter Stephenson
@ 2015-02-13 15:52 ` Peter Stephenson
2015-02-13 21:11 ` John Eikenberry
2015-02-13 22:17 ` Mikael Magnusson
1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2015-02-13 15:52 UTC (permalink / raw)
To: Zsh Users
On Fri, 13 Feb 2015 15:41:38 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> You can easily search backward for a
> file of the same name in a parent directory if you have EXTENDED_GLOB
> set: (../)#.thatdotfilename which will allow you to put in the top level
> of a repository.
Come to think of it, that can produce multiple matches.
(../)#foo(oL[1])
gets you the first one you encounter going up (the one with the shortest
name).
pws
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: directory specific functions and aliases
2015-02-13 15:52 ` Peter Stephenson
@ 2015-02-13 21:11 ` John Eikenberry
0 siblings, 0 replies; 5+ messages in thread
From: John Eikenberry @ 2015-02-13 21:11 UTC (permalink / raw)
To: zsh-users
[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]
Peter Stephenson wrote:
> On Fri, 13 Feb 2015 15:41:38 +0000
> Peter Stephenson <p.stephenson@samsung.com> wrote:
> > You can easily search backward for a
> > file of the same name in a parent directory if you have EXTENDED_GLOB
> > set: (../)#.thatdotfilename which will allow you to put in the top level
> > of a repository.
>
> Come to think of it, that can produce multiple matches.
>
> (../)#foo(oL[1])
>
> gets you the first one you encounter going up (the one with the shortest
> name).
I also use this for a local history and have found it made more sense to get
the one with the longest name, the one 'closer' to you in the tree. I also
found expanding the name useful (the :a). I use this...
(../)#.zsh_history(oL[-1]:a))
--
John Eikenberry
[ jae@zhar.net - http://zhar.net ]
[ PGP public key @ http://zhar.net/jae_at_zhar_net.gpg ]
________________________________________________________________________
"Perfection is attained, not when no more can be added, but when no more
can be removed." -- Antoine de Saint-Exupery
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: directory specific functions and aliases
2015-02-13 15:41 ` Peter Stephenson
2015-02-13 15:52 ` Peter Stephenson
@ 2015-02-13 22:17 ` Mikael Magnusson
1 sibling, 0 replies; 5+ messages in thread
From: Mikael Magnusson @ 2015-02-13 22:17 UTC (permalink / raw)
To: Peter Stephenson; +Cc: Zsh Users
On Fri, Feb 13, 2015 at 4:41 PM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Fri, 13 Feb 2015 10:05:21 -0500
> shawn wilson <ag4ve.us@gmail.com> wrote:
>> What would be the best way to make functions that do different things
>> based on the directory I'm in - kinda like rvm does with rubies? I was
>> hoping for something cleaner than: case $(pwd) This is mainly because
>> I want to wrap cvs and rsync differently based on repo (and where
>> within that repo).
>
> I use a dot-file in the directory, but you need to be careful with this
> --- at least check you own the file before using it for extracting
> commands or anything of that kind.
I would check both the file and the containing directory; anyone can
create hardlinks to files you own in their own directories, and a
command that's safe in one directory may not be in another.
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-02-13 22:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-13 15:05 directory specific functions and aliases shawn wilson
2015-02-13 15:41 ` Peter Stephenson
2015-02-13 15:52 ` Peter Stephenson
2015-02-13 21:11 ` John Eikenberry
2015-02-13 22:17 ` Mikael Magnusson
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).