mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-23 00:03:24 +01:00
Fix dirpersist plugin
This plugin did not work, I just found the same functionnality in grml, this one works.
This commit is contained in:
parent
ca90021630
commit
ef343eef30
@ -1,39 +1,19 @@
|
|||||||
#!/bin/zsh
|
# Save dirstack history to .zdirs
|
||||||
#
|
# adapted from:
|
||||||
# Make the dirstack more persistant
|
# github.com/grml/grml-etc-core/blob/master/etc/zsh/zshrc#L1547
|
||||||
#
|
|
||||||
# Add dirpersist to $plugins in ~/.zshrc to load
|
|
||||||
#
|
|
||||||
|
|
||||||
# $zdirstore is the file used to persist the stack
|
DIRSTACKSIZE=${DIRSTACKSIZE:-20}
|
||||||
zdirstore=~/.zdirstore
|
dirstack_file=${dirstack_file:-${HOME}/.zdirs}
|
||||||
|
|
||||||
dirpersistinstall () {
|
if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
|
||||||
if grep 'dirpersiststore' ~/.zlogout > /dev/null; then
|
dirstack=( ${(f)"$(< $dirstack_file)"} )
|
||||||
else
|
# "cd -" won't work after login by just setting $OLDPWD, so
|
||||||
if read -q \?"Would you like to set up your .zlogout file for use with dirspersist? (y/n) "; then
|
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
|
||||||
echo "# Store dirs stack\n# See $ZSH/plugins/dirspersist.plugin.zsh\ndirpersiststore" >> ~/.zlogout
|
fi
|
||||||
else
|
|
||||||
echo "If you don't want this message to appear, remove dirspersist from \$plugins"
|
chpwd() {
|
||||||
fi
|
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
|
||||||
fi
|
local -ax my_stack
|
||||||
|
my_stack=( ${PWD} ${dirstack} )
|
||||||
|
builtin print -l ${(u)my_stack} >! ${dirstack_file}
|
||||||
}
|
}
|
||||||
|
|
||||||
dirpersiststore () {
|
|
||||||
dirs -p | perl -e 'foreach (reverse <STDIN>) {chomp;s/([& ])/\\$1/g ;print "if [ -d $_ ]; then pushd -q $_; fi\n"}' > $zdirstore
|
|
||||||
}
|
|
||||||
|
|
||||||
dirpersistrestore () {
|
|
||||||
if [ -f $zdirstore ]; then
|
|
||||||
source $zdirstore
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
DIRSTACKSIZE=10
|
|
||||||
setopt autopushd pushdminus pushdsilent pushdtohome pushdignoredups
|
|
||||||
|
|
||||||
dirpersistinstall
|
|
||||||
dirpersistrestore
|
|
||||||
|
|
||||||
# Make popd changes permanent without having to wait for logout
|
|
||||||
alias popd="popd;dirpersiststore"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user