zsh-users
 help / color / mirror / code / Atom feed
* howto avoid ~irc in %~ ?
@ 2002-06-14 18:16 Andy Spiegl
  2002-06-15 23:22 ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Spiegl @ 2002-06-14 18:16 UTC (permalink / raw)
  To: ZSH User List

Hi,

I am afraid there is no good solution to this, but better ask:

I use %~ in my prompt, which is great, but in my /etc/passwd are some
strange home directories, like:
 irc:x:39:39:ircd:/var:/bin/sh

So when I change to
 /var/www
my prompt is:
 machine:~irc/www>

Is there any way to tell zsh, to only use the ~... shortcut for home
directories in /home, or maybe for some specific users?

Thanks,
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 A chicken crossing the road is poultry in motion.


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

* Re: howto avoid ~irc in %~ ?
  2002-06-14 18:16 howto avoid ~irc in %~ ? Andy Spiegl
@ 2002-06-15 23:22 ` Bart Schaefer
  2002-06-17  7:12   ` Wayne Davison
  0 siblings, 1 reply; 12+ messages in thread
From: Bart Schaefer @ 2002-06-15 23:22 UTC (permalink / raw)
  To: Andy Spiegl, zsh-users

On Jun 14,  1:16pm, Andy Spiegl wrote:
} 
} I use %~ in my prompt [but then] when I change to
}  /var/www
} my prompt is:
}  machine:~irc/www>

Zsh doesn't do this all by itself.  You must at some point have used ~irc
before zsh would add an entry for irc to its hash table of named dirs.

E.g. starting from `zsh -f':

zagzig% cd /home/ftp
zagzig% pwd
/home/ftp
zagzig% print -P %~
/home/ftp

But:

zagzig% cd ~ftp
zagzig% pwd
/home/ftp
zagzig% print -P %~
~ftp

So if you don't want zsh to use the abbreviations, don't use them yourself.

Zsh does have a rule that it won't show the tilde-form if the real name of
the directory is shorter, but in the case of ~irc and /var they happen to
be exactly the same length.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: howto avoid ~irc in %~ ?
  2002-06-15 23:22 ` Bart Schaefer
@ 2002-06-17  7:12   ` Wayne Davison
  2002-06-21 22:51     ` Andy Spiegl
  0 siblings, 1 reply; 12+ messages in thread
From: Wayne Davison @ 2002-06-17  7:12 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Andy Spiegl, zsh-users

On Sat, 15 Jun 2002, Bart Schaefer wrote:
> Zsh doesn't do this all by itself.  You must at some point have used ~irc
> before zsh would add an entry for irc to its hash table of named dirs.

Completing ~ names will also add it for you.  For instance, if I type
"~w<TAB>" and get "~wayne", all other user home dirs have now been
cached.

..wayne..


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

* Re: howto avoid ~irc in %~ ?
  2002-06-17  7:12   ` Wayne Davison
@ 2002-06-21 22:51     ` Andy Spiegl
  2002-06-21 23:11       ` Dan Nelson
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Spiegl @ 2002-06-21 22:51 UTC (permalink / raw)
  To: zsh-users

Hi Bart and Wayne,

I was really surprised to read this:
> > Zsh doesn't do this all by itself.  You must at some point have used ~irc
> > before zsh would add an entry for irc to its hash table of named dirs.
because I never use ~irc.

But Waynes comment explains it: 
> Completing ~ names will also add it for you.  For instance, if I type
> "~w<TAB>" and get "~wayne", all other user home dirs have now been
> cached.

So I guess there is no way to avoid ~irc to appear instead of /var.
Hm, unless I remove it from the cache.  But how would I do that???

Thanks,
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Weinberg's Principle:
     An expert is a person who avoids the small errors while
     sweeping on to the grand fallacy.


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

* Re: howto avoid ~irc in %~ ?
  2002-06-21 22:51     ` Andy Spiegl
@ 2002-06-21 23:11       ` Dan Nelson
  2002-06-21 23:40         ` Andy Spiegl
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Nelson @ 2002-06-21 23:11 UTC (permalink / raw)
  To: zsh-users

In the last episode (Jun 21), Andy Spiegl said:
> Hi Bart and Wayne,
> 
> I was really surprised to read this:
> > > Zsh doesn't do this all by itself.  You must at some point have used ~irc
> > > before zsh would add an entry for irc to its hash table of named dirs.
> because I never use ~irc.
> 
> But Waynes comment explains it: 
> > Completing ~ names will also add it for you.  For instance, if I type
> > "~w<TAB>" and get "~wayne", all other user home dirs have now been
> > cached.
> 
> So I guess there is no way to avoid ~irc to appear instead of /var.
> Hm, unless I remove it from the cache.  But how would I do that???

How about

chpwd() { unhash -d irc }

This lets you still use ~irc if you want, but by the time zsh gets
around to parsing %~, it'll be out of the hash.

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

* Re: howto avoid ~irc in %~ ?
  2002-06-21 23:11       ` Dan Nelson
@ 2002-06-21 23:40         ` Andy Spiegl
  2002-06-21 23:53           ` Dan Nelson
  2002-06-21 23:54           ` Bart Schaefer
  0 siblings, 2 replies; 12+ messages in thread
From: Andy Spiegl @ 2002-06-21 23:40 UTC (permalink / raw)
  To: zsh-users

Oops, I reacted too fast :-)

> chpwd() { unhash -d irc }
This works great, if irc still is in the hash, but throws:
  unhash: no such hash table element: irc
after every directory change if it isn't.

Hm, how would I test if it is in the hash before removing it?
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 When I shop for hardware I always look for the "Designed for Windows"
 logo.  I really thank Microsoft(TM) for encouraging manufacturers to
 label their products this way, so I know what to AVOID.


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

* Re: howto avoid ~irc in %~ ?
  2002-06-21 23:40         ` Andy Spiegl
@ 2002-06-21 23:53           ` Dan Nelson
  2002-06-21 23:54           ` Bart Schaefer
  1 sibling, 0 replies; 12+ messages in thread
From: Dan Nelson @ 2002-06-21 23:53 UTC (permalink / raw)
  To: zsh-users

In the last episode (Jun 21), Andy Spiegl said:
> Oops, I reacted too fast :-)
> 
> > chpwd() { unhash -d irc }
> This works great, if irc still is in the hash, but throws:
>   unhash: no such hash table element: irc
> after every directory change if it isn't.
>
> Hm, how would I test if it is in the hash before removing it?

chpwd() { unhash -d irc 2>& /dev/null }

masks it; that's probably as good as you can get.

-- 
	Dan Nelson
	dnelson@allantgroup.com


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

* Re: howto avoid ~irc in %~ ?
  2002-06-21 23:40         ` Andy Spiegl
  2002-06-21 23:53           ` Dan Nelson
@ 2002-06-21 23:54           ` Bart Schaefer
  2002-06-21 23:59             ` Will Yardley
  2002-06-22  0:41             ` Andy Spiegl
  1 sibling, 2 replies; 12+ messages in thread
From: Bart Schaefer @ 2002-06-21 23:54 UTC (permalink / raw)
  To: Andy Spiegl; +Cc: zsh-users

On Fri, 21 Jun 2002, Andy Spiegl wrote:

> > chpwd() { unhash -d irc }
>
> Hm, how would I test if it is in the hash before removing it?

If you're really never going to use ~irc, then just do

	irc=/

and that will change the value in the hash.  Since "/" is shorter than
"~irc", zsh will never display ~irc again.


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

* Re: howto avoid ~irc in %~ ?
  2002-06-21 23:54           ` Bart Schaefer
@ 2002-06-21 23:59             ` Will Yardley
  2002-06-22  0:41             ` Andy Spiegl
  1 sibling, 0 replies; 12+ messages in thread
From: Will Yardley @ 2002-06-21 23:59 UTC (permalink / raw)
  To: zsh-users

Bart Schaefer wrote:
> On Fri, 21 Jun 2002, Andy Spiegl wrote:
 
> > > chpwd() { unhash -d irc }
> >
> > Hm, how would I test if it is in the hash before removing it?
> 
> If you're really never going to use ~irc, then just do
> 
> 	irc=/
> 
> and that will change the value in the hash.  Since "/" is shorter than
> "~irc", zsh will never display ~irc again.

if you have root access, and if you don't use the user 'irc' at all, you
could just remove the user from the system entirely.

-- 
Will Yardley
input: william < @ hq . newdream . net . >


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

* Re: howto avoid ~irc in %~ ?
  2002-06-21 23:54           ` Bart Schaefer
  2002-06-21 23:59             ` Will Yardley
@ 2002-06-22  0:41             ` Andy Spiegl
  2002-06-22  0:57               ` Clint Adams
  2002-06-22  2:04               ` Wayne Davison
  1 sibling, 2 replies; 12+ messages in thread
From: Andy Spiegl @ 2002-06-22  0:41 UTC (permalink / raw)
  To: zsh-users

> If you're really never going to use ~irc, then just do
> 
> 	irc=/
> 
> and that will change the value in the hash.  Since "/" is shorter than
> "~irc", zsh will never display ~irc again.

And this won't have any side effects?  Like irc not finding some files or so?

Thanks,
 Andy.

-- 
           http://peru.spiegl.de  Our project
      http://radiomaranon.org.pe  Radio Marañón, Jaén, Perú
                              o      _     _         _
  ------- __o       __o      /\_   _ \\o  (_)\__/o  (_)          -o)
  ----- _`\<,_    _`\<,_    _>(_) (_)/<_    \_| \   _|/' \/       /\\
  ---- (_)/ (_)  (_)/ (_)  (_)        (_)   (_)    (_)'  _\o_    _\_v
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 "We're going to turn this team around 360 degrees."
      (Jason Kidd, upon his drafting to the Dallas Mavericks)


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

* Re: howto avoid ~irc in %~ ?
  2002-06-22  0:41             ` Andy Spiegl
@ 2002-06-22  0:57               ` Clint Adams
  2002-06-22  2:04               ` Wayne Davison
  1 sibling, 0 replies; 12+ messages in thread
From: Clint Adams @ 2002-06-22  0:57 UTC (permalink / raw)
  To: zsh-users

> And this won't have any side effects?  Like irc not finding some files or so?

I imagine that that user is for an ircd.


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

* Re: howto avoid ~irc in %~ ?
  2002-06-22  0:41             ` Andy Spiegl
  2002-06-22  0:57               ` Clint Adams
@ 2002-06-22  2:04               ` Wayne Davison
  1 sibling, 0 replies; 12+ messages in thread
From: Wayne Davison @ 2002-06-22  2:04 UTC (permalink / raw)
  To: Andy Spiegl; +Cc: zsh-users

On Fri, 21 Jun 2002, Andy Spiegl wrote:
> Bart suggested
> > 	irc=/
> 
> And this won't have any side effects?  Like irc not finding some files
> or so?

Since you're only giving "irc" a value in your environment, it won't
affect others, and it won't affect anything that looks up the actual
home dir of irc that you might run, so you should be fine.

..wayne..


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

end of thread, other threads:[~2002-06-22  2:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-14 18:16 howto avoid ~irc in %~ ? Andy Spiegl
2002-06-15 23:22 ` Bart Schaefer
2002-06-17  7:12   ` Wayne Davison
2002-06-21 22:51     ` Andy Spiegl
2002-06-21 23:11       ` Dan Nelson
2002-06-21 23:40         ` Andy Spiegl
2002-06-21 23:53           ` Dan Nelson
2002-06-21 23:54           ` Bart Schaefer
2002-06-21 23:59             ` Will Yardley
2002-06-22  0:41             ` Andy Spiegl
2002-06-22  0:57               ` Clint Adams
2002-06-22  2:04               ` Wayne Davison

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