Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: persistant Directory history?
- X-seq: zsh-users 10952
- From: Francisco Borges <f.borges@xxxxxx>
- To: chesss <testingagain@xxxxxxxxx>
- Subject: Re: persistant Directory history?
- Date: Tue, 7 Nov 2006 15:52:31 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <5db995410611060845y53f673e6je029a9c60659f116@xxxxxxxxxxxxxx>
- Mail-followup-to: chesss <testingagain@xxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: Alfa Informatica - Rijksuniversiteit Groningen
- References: <5db995410611060845y53f673e6je029a9c60659f116@xxxxxxxxxxxxxx>
: On Mon, Nov 06, 2006 at 10:15PM +0530, chesss wrote:
> Basically I want to save the directory stack automatically and have
> ctrl+r like history..
> Possible?
I really wish the zsh-devs would include something for this in Zsh.
After I started having a persistent dirstack, I really had to wonder how
I had lived without it for so long :-)
Turns out there is a lot of people with custom ways to implement it.
[...]
As Stephane pointed out, all you need to do is to somehow set the
dirstack variable when you log in.
But I rather rewrite the zsh_dir_file everytime I change dirs. instead
of only after logout. Also (making a long story short) right after
login, just setting $OLDPWD won't allow you to use
% cd -
so I force the shell to visit the first dir in the stack to be able to
have this.
#-------------------------------------------------
# http://www.zsh.org/mla/users/2006/msg00173.html
# Adding a (rather primitive) dirstack history
DIRSTACKSIZE=20
if [[ -f ~/.zdirs ]] && [[ ${#dirstack[*]} -eq 0 ]]; then
dirstack=( ${(uf)"$(< ~/.zdirs)"} )
# "cd -" won't work after login by just setting $OLDPWD, so
cd $dirstack[0] && cd - > /dev/null
fi
chpwd() { dirs -pl >! ~/.zdirs }
#-------------------------------------------------
My 2 cents on the topic....
Cheers,
--
Francisco Borges
Messages sorted by:
Reverse Date,
Date,
Thread,
Author