ae1f33178285beb1560f4e6838a23335cfce29ef

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

Message

Merge pull request #1005 from cmar/powed

pow plugin - commands to restart pow and list urls

Diff

 1diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh
 2index 399a54cb02aae802afb95f72a343b35b1412f779..7f86c0c76ed9e051a28aa82519d11776d0c05add 100644
 3--- a/plugins/pow/pow.plugin.zsh
 4+++ b/plugins/pow/pow.plugin.zsh
 5@@ -8,18 +8,18 @@
 6 # Supports command completion.
 7 #
 8 # If you are not already using completion you might need to enable it with
 9-# 
10+#
11 #    autoload -U compinit compinit
12 #
13 # Changes:
14 #
15-# Defaults to the current application, and will walk up the tree to find 
16+# Defaults to the current application, and will walk up the tree to find
17 # a config.ru file and restart the corresponding app
18 #
19-# Will Detect if a app does not exist in pow and print a (slightly) helpful 
20+# Will Detect if a app does not exist in pow and print a (slightly) helpful
21 # error message
22 
23-rack_root_detect(){
24+rack_root(){
25   setopt chaselinks
26   local orgdir=$(pwd)
27   local basedir=$(pwd)
28@@ -32,6 +32,11 @@ rack_root_detect(){
29 
30   builtin cd $orgdir 2>/dev/null
31   [[ ${basedir} == "/" ]] && return 1
32+  echo $basedir
33+}
34+
35+rack_root_detect(){
36+  basedir=$(rack_root)
37   echo `basename $basedir | sed -E "s/.(com|net|org)//"`
38 }
39 
40@@ -51,16 +56,30 @@ kapow(){
41 compctl -W ~/.pow -/ kapow
42 
43 powit(){
44-	local basedir=$(pwd)
45+  local basedir=$(pwd)
46   local vhost=$1
47   [ ! -n "$vhost" ] && vhost=$(rack_root_detect)
48   if [ ! -h ~/.pow/$vhost ]
49-	then
50-		echo "pow: Symlinking your app with pow. ${vhost}"
51-	  [ ! -d ~/.pow/${vhost} ] && ln -s $basedir ~/.pow/$vhost
52+  then
53+    echo "pow: Symlinking your app with pow. ${vhost}"
54+    [ ! -d ~/.pow/${vhost} ] && ln -s $basedir ~/.pow/$vhost
55     return 1
56   fi
57 }
58 
59+powed(){
60+  local basedir=$(rack_root)
61+  find ~/.pow/ -type l -lname "*$basedir*" -exec basename {}'.dev' \;
62+}
63+
64+# Restart pow process
65+# taken from http://www.matthewratzloff.com/blog/2011/12/23/restarting-pow-when-dns-stops-responding
66+repow(){
67+  lsof | grep 20560 | awk '{print $2}' | xargs kill -9
68+  launchctl unload ~/Library/LaunchAgents/cx.pow.powd.plist
69+  launchctl load ~/Library/LaunchAgents/cx.pow.powd.plist
70+  echo "restarted pow"
71+}
72+
73 # View the standard out (puts) from any pow app
74-alias kaput="tail -f ~/Library/Logs/Pow/apps/*"
75+alias kaput="tail -f ~/Library/Logs/Pow/apps/*"