* On setting OLDPWD
@ 2014-01-10 19:15 Christian Neukirchen
2014-01-10 23:50 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Christian Neukirchen @ 2014-01-10 19:15 UTC (permalink / raw)
To: zsh-users
Hi,
I'm using this small snippet to persist and share my dirstack across
multiple zsh:
DIRSTACKSIZE=9
DIRSTACKFILE=~/.zdirs
if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then
dirstack=( ${(f)"$(< $DIRSTACKFILE)"} )
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi
chpwd() {
local -a dirs; dirs=( "$PWD" ${(f)"$(< $DIRSTACKFILE)"} )
print -l ${${(u)dirs}[0,$DIRSTACKSIZE]} >$DIRSTACKFILE
}
This works very nicely, except for the case $dirstack[1] is on a "stuck"
directory (e.g. a stale NFS or a broken FUSE device). In that case,
zsh nicely locks up during start.
Is there any way to change where "cd -" would go to, without actually
cd'ing there? (Setting dirstack is not enough, it works for "cd -1" but
not for "cd -". Setting OLDPWD doesn't help either.)
Ideas?
--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: On setting OLDPWD
2014-01-10 19:15 On setting OLDPWD Christian Neukirchen
@ 2014-01-10 23:50 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2014-01-10 23:50 UTC (permalink / raw)
To: Christian Neukirchen, zsh-users
On Jan 10, 8:15pm, Christian Neukirchen wrote:
}
} Is there any way to change where "cd -" would go to, without actually
} cd'ing there?
No, there isn't. "cd -" uses a directory name stored in an internal
data field. The value of $OLDPWD is reset to the same string as that
internal field upon each change of directory, but is not tied to it
in any other way; only the "cd" command (and its relatives) alter it.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-01-10 23:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-10 19:15 On setting OLDPWD Christian Neukirchen
2014-01-10 23:50 ` Bart Schaefer
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).