72aa4ddb10b40d61bfc1817a04d4cedd10d25f7e

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #2257 from mfaerevaag/master

Added wd plugin

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/wd2/wd2/wd.plugin.zsh b/plugins/wd2/wd2/wd.plugin.zsh
  2new file mode 100755
  3index 0000000000000000000000000000000000000000..e0846ffd9037c95969453445002d2e52ca278eba
  4--- /dev/null
  5+++ b/plugins/wd2/wd2/wd.plugin.zsh
  6@@ -0,0 +1,9 @@
  7+#!/bin/zsh
  8+
  9+# WARP
 10+# ====
 11+# oh-my-zsh plugin
 12+#
 13+# @github.com/mfaerevaag/wd
 14+
 15+alias wd='. ~/.oh-my-zsh/plugins/wd/wd.sh'
 16diff --git a/plugins/wd2/wd2/wd.sh b/plugins/wd2/wd2/wd.sh
 17new file mode 100755
 18index 0000000000000000000000000000000000000000..7852028c061c8a96f411ecf286afa01b82e5e6aa
 19--- /dev/null
 20+++ b/plugins/wd2/wd2/wd.sh
 21@@ -0,0 +1,201 @@
 22+#!/bin/zsh
 23+
 24+# WARP
 25+# ====
 26+# Jump to custom directories in terminal
 27+# because `cd` takes too long...
 28+#
 29+# @github.com/mfaerevaag/wd
 30+
 31+
 32+## variables
 33+CONFIG=$HOME/.warprc
 34+
 35+## colors
 36+BLUE="\033[96m"
 37+GREEN="\033[92m"
 38+YELLOW="\033[93m"
 39+RED="\033[91m"
 40+NOC="\033[m"
 41+
 42+
 43+## load warp points
 44+typeset -A points
 45+while read line
 46+do
 47+    arr=(${(s,:,)line})
 48+    key=${arr[1]}
 49+    val=${arr[2]}
 50+
 51+    points[$key]=$val
 52+done < $CONFIG
 53+
 54+
 55+## functions
 56+# prepended wd_ to not conflict with your environment (no sub shell)
 57+
 58+wd_warp()
 59+{
 60+    if [[ $1 =~ "^\.+$" ]]
 61+    then
 62+        if [[ $#1 < 2 ]]
 63+        then
 64+            wd_print_msg $YELLOW "Warping to current directory?"
 65+        else
 66+            (( n = $#1 - 1 ))
 67+            wd_print_msg $BLUE "Warping..."
 68+            cd -$n > /dev/null
 69+        fi
 70+    elif [[ ${points[$1]} != "" ]]
 71+    then
 72+        wd_print_msg $BLUE "Warping..."
 73+        cd ${points[$1]}
 74+    else
 75+        wd_print_msg $RED "Unkown warp point '$1'"
 76+    fi
 77+}
 78+
 79+wd_add()
 80+{
 81+    if [[ $1 =~ "^\.+$" ]]
 82+    then
 83+        wd_print_msg $RED "Illeagal warp point (see README)."
 84+    elif [[ ${points[$1]} == "" ]] || $2
 85+    then
 86+        wd_remove $1 > /dev/null
 87+        print "$1:$PWD" >> $CONFIG
 88+        wd_print_msg $GREEN "Warp point added"
 89+    else
 90+        wd_print_msg $YELLOW "Warp point '$1' alredy exists. Use 'add!' to overwrite."
 91+    fi
 92+}
 93+
 94+wd_remove()
 95+{
 96+    if [[ ${points[$1]} != "" ]]
 97+    then
 98+        if wd_tmp=`sed "/^$1:/d" $CONFIG`
 99+        then
100+            echo $wd_tmp > $CONFIG
101+            wd_print_msg $GREEN "Warp point removed"
102+        else
103+            wd_print_msg $RED "Warp point unsuccessfully removed. Sorry!"
104+        fi
105+    else
106+        wd_print_msg $RED "Warp point was not found"
107+    fi
108+}
109+
110+wd_show()
111+{
112+    wd_print_msg $BLUE "Warp points to current directory:"
113+    wd_list_all | grep $PWD$
114+}
115+
116+wd_list_all()
117+{
118+    wd_print_msg $BLUE "All warp points:"
119+    while read line
120+    do