Add BOOKMARKing functionality to dirs plugin
authorYakkala Yagnesh Raghava <yagnesh@live.com>
Fri, 5 Aug 2011 15:14:15 +0000 (00:14 +0900)
committerYakkala Yagnesh Raghava <yagnesh@live.com>
Fri, 5 Aug 2011 15:14:15 +0000 (00:14 +0900)
plugins/available/dirs.plugins.bash [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index dfa9a32..a9f5974
@@ -50,3 +50,35 @@ function dirs-help() {
   echo "8      : Chance to stack location 8."
   echo "9      : Chance to stack location 9."
 }
+
+
+# ADD BOOKMARKing functionality
+# usage:
+
+if [ ! -f ~/.dirs ]; then  # if doesn't exist, create it
+    touch ~/.dirs
+else
+    source ~/.dirs
+fi
+
+alias L='cat ~/.dirs'
+
+G () {                         # goes to distination dir otherwise , stay in the dir
+    cd ${1:-$(pwd)} ;
+}
+
+S () {                         # SAVE a BOOKMARK
+    /bin/sed "/$@/d" ~/.dirs > ~/.dirs1;
+    \mv ~/.dirs1 ~/.dirs;
+    echo "$@"=\"`pwd`\" >> ~/.dirs;
+    source ~/.dirs ;
+}
+
+R () {                         # remove a BOOKMARK
+    /bin/sed "/$@/d" ~/.dirs > ~/.dirs1;
+    \mv ~/.dirs1 ~/.dirs;
+}
+
+alias U='source ~/.dirs'       # Update BOOKMARK stack
+# set the bash option so that no '$' is required when using the above facility
+shopt -s cdable_vars