[issue1567] grml-zshrc: broken dirstack handling

Frank Terbeck bts at bts.grml.org
Tue Jul 21 00:16:08 CEST 2015


Frank Terbeck <ft at grml.org> added the comment:

On IRC, I asked mika for to try this:

diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc
index b6c8375..72fde6e 100644
--- a/etc/zsh/zshrc
+++ b/etc/zsh/zshrc
@@ -1622,7 +1622,7 @@ if [[ -f ${DIRSTACKFILE} ]] && [[ ${#dirstack[*]} -eq 0 ]]
; then
     # directories from the saved dir-stack file.
     dirstack=( ${(f)"$(< $DIRSTACKFILE)"}(N) )
     # "cd -" won't work after login by just setting $OLDPWD, so
-    [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
+    [[ -d $dirstack[1] ]] && cd -q $dirstack[1] && cd -q $OLDPWD
 fi

 if zstyle -T ':grml:chpwd:dirstack' filter-on-load; then

His reply:

> looks better AFAICT! just /home/mika is in the "temporary" dirstack
> (not ~/.zdirs though!) twice, unsure whether that's wanted or not.

So that's a start.

The idea is to use "-q" so the implicit chdirs don't trigger the
chpwd() hook function.

Mika: If you can reproduce the "weird directories in dirstack" issue,
please try the following and paste the result in here (it'll produce
a fair bit of output on the commandline as zsh starts up):

diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc
index 72fde6e..ebc5678 100644
--- a/etc/zsh/zshrc
+++ b/etc/zsh/zshrc
@@ -1588,12 +1588,13 @@ isgrmlcd && HISTSIZE=500  || HISTSIZE=5000
 isgrmlcd && SAVEHIST=1000 || SAVEHIST=10000 # useful for setopt append_history
 
 # dirstack handling
-
+set -x
 DIRSTACKSIZE=${DIRSTACKSIZE:-20}
 DIRSTACKFILE=${DIRSTACKFILE:-${ZDOTDIR:-${HOME}}/.zdirs}
 
 typeset -gaU GRML_PERSISTENT_DIRSTACK
 function grml_dirstack_filter() {
+    setopt local_options xtrace
     local -a exclude
     local filter entry
     if zstyle -s ':grml:chpwd:dirstack' filter filter; then
@@ -1608,6 +1609,7 @@ function grml_dirstack_filter() {
 }
 
 chpwd() {
+    setopt local_options xtrace
     (( $DIRSTACKSIZE <= 0 )) && return
     [[ -z $DIRSTACKFILE ]] && return
     grml_dirstack_filter $PWD && return
@@ -1637,6 +1639,7 @@ if zstyle -T ':grml:chpwd:dirstack' filter-on-load; then
 else
     GRML_PERSISTENT_DIRSTACK=( "${dirstack[@]}" )
 fi
+set +x
 
 # directory based profiles
 

Regards, Frank

----------
assignedto: ft
messages: 5192, 5193
nosy: ft, mika
priority: bug
status: chatting
title: grml-zshrc: broken dirstack handling

_____________________________________
GRML issue tracker <bts at bts.grml.org>
<http://bts.grml.org/grml/issue1567>
_____________________________________


More information about the Bugs-changes mailing list