Browse code

Merge branch 'dirpersist' of http://github.com/curiousstranger/oh-my-zsh into curiousstranger-dirpersist

Robby Russell authored on 01/10/2010 at 04:01:57
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,39 @@
0
+#!/bin/zsh
1
+# 
2
+# Make the dirstack more persistant
3
+# 
4
+# Add dirpersist to $plugins in ~/.zshrc to load
5
+# 
6
+
7
+# $zdirstore is the file used to persist the stack
8
+zdirstore=~/.zdirstore
9
+
10
+dirpersistinstall () {
11
+    if grep 'dirpersiststore' ~/.zlogout > /dev/null; then
12
+    else
13
+        if read -q \?"Would you like to set up your .zlogout file for use with dirspersist? (y/n) "; then
14
+            echo "# Store dirs stack\n# See ~/.oh-my-zsh/plugins/dirspersist.plugin.zsh\ndirpersiststore" >> ~/.zlogout
15
+        else
16
+            echo "If you don't want this message to appear, remove dirspersist from \$plugins"
17
+        fi
18
+    fi
19
+}
20
+
21
+dirpersiststore () {
22
+    dirs -p | perl -e 'foreach (reverse <STDIN>) {chomp;s/([& ])/\\$1/g ;print "if [ -d $_ ]; then pushd -q $_; fi\n"}' > $zdirstore
23
+}
24
+
25
+dirpersistrestore () {
26
+    if [ -f $zdirstore ]; then
27
+        source $zdirstore
28
+    fi
29
+}
30
+
31
+DIRSTACKSIZE=10
32
+setopt autopushd pushdminus pushdsilent pushdtohome pushdignoredups
33
+
34
+dirpersistinstall
35
+dirpersistrestore
36
+
37
+# Make popd changes permanent without having to wait for logout
38
+alias popd="popd;dirpersiststore"