summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2010-09-30 21:01:57 -0700
committerRobby Russell <robby@planetargon.com>2010-09-30 21:01:57 -0700
commit88293b305a217d097dc425c1920590e4d018c5ff (patch)
tree33cb4a47c73abf0e7d26fdddd69c211d71f7310a
parentb9056303669806be8e1e90eacfc471590c39f353 (diff)
parent3add6a2ac47186240a2d02a986ae22b6519d965f (diff)
downloadzsh-88293b305a217d097dc425c1920590e4d018c5ff.tar.gz
zsh-88293b305a217d097dc425c1920590e4d018c5ff.tar.bz2
zsh-88293b305a217d097dc425c1920590e4d018c5ff.zip
Merge branch 'dirpersist' of http://github.com/curiousstranger/oh-my-zsh into curiousstranger-dirpersist
-rw-r--r--plugins/dirpersist.plugin.zsh39
1 files changed, 39 insertions, 0 deletions
diff --git a/plugins/dirpersist.plugin.zsh b/plugins/dirpersist.plugin.zsh
new file mode 100644
index 000000000..6a2b289a2
--- /dev/null
+++ b/plugins/dirpersist.plugin.zsh
@@ -0,0 +1,39 @@
+#!/bin/zsh
+#
+# Make the dirstack more persistant
+#
+# Add dirpersist to $plugins in ~/.zshrc to load
+#
+
+# $zdirstore is the file used to persist the stack
+zdirstore=~/.zdirstore
+
+dirpersistinstall () {
+ if grep 'dirpersiststore' ~/.zlogout > /dev/null; then
+ else
+ if read -q \?"Would you like to set up your .zlogout file for use with dirspersist? (y/n) "; then
+ echo "# Store dirs stack\n# See ~/.oh-my-zsh/plugins/dirspersist.plugin.zsh\ndirpersiststore" >> ~/.zlogout
+ else
+ echo "If you don't want this message to appear, remove dirspersist from \$plugins"
+ fi
+ fi
+}
+
+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"