Merge pull request #850 from johnantoni/pow-fix
take in chris sexton's changes to the pow plugin
Diff
1diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh
2index 6b2a6f2be0f3636c9026eb82a0405eebc79669b4..399a54cb02aae802afb95f72a343b35b1412f779 100644
3--- a/plugins/pow/pow.plugin.zsh
4+++ b/plugins/pow/pow.plugin.zsh
5@@ -1,10 +1,66 @@
6-# Thanks to Christopher Sexton
7-# https://gist.github.com/965032
8-function kapow {
9- touch ~/.pow/$1/tmp/restart.txt
10- if [ $? -eq 0 ]; then
11- echo "$fg[yellow]Pow restarting $1...$reset_color"
12- fi
13+# Restart a rack app running under pow
14+# http://pow.cx/
15+#
16+# Adds a kapow command that will restart an app
17+#
18+# $ kapow myapp
19+#
20+# Supports command completion.
21+#
22+# If you are not already using completion you might need to enable it with
23+#
24+# autoload -U compinit compinit
25+#
26+# Changes:
27+#
28+# Defaults to the current application, and will walk up the tree to find
29+# a config.ru file and restart the corresponding app
30+#
31+# Will Detect if a app does not exist in pow and print a (slightly) helpful
32+# error message
33+
34+rack_root_detect(){
35+ setopt chaselinks
36+ local orgdir=$(pwd)
37+ local basedir=$(pwd)
38+
39+ while [[ $basedir != '/' ]]; do
40+ test -e "$basedir/config.ru" && break
41+ builtin cd ".." 2>/dev/null
42+ basedir="$(pwd)"
43+ done
44+
45+ builtin cd $orgdir 2>/dev/null
46+ [[ ${basedir} == "/" ]] && return 1
47+ echo `basename $basedir | sed -E "s/.(com|net|org)//"`
48 }
4950+kapow(){
51+ local vhost=$1
52+ [ ! -n "$vhost" ] && vhost=$(rack_root_detect)
53+ if [ ! -h ~/.pow/$vhost ]
54+ then
55+ echo "pow: This domain isn’t set up yet. Symlink your application to ${vhost} first."
56+ return 1
57+ fi
58+
59+ [ ! -d ~/.pow/${vhost}/tmp ] && mkdir -p ~/.pow/$vhost/tmp
60+ touch ~/.pow/$vhost/tmp/restart.txt;
61+ [ $? -eq 0 ] && echo "pow: restarting $vhost.dev"
62+}
63 compctl -W ~/.pow -/ kapow
64+
65+powit(){
66+ local basedir=$(pwd)
67+ local vhost=$1
68+ [ ! -n "$vhost" ] && vhost=$(rack_root_detect)
69+ if [ ! -h ~/.pow/$vhost ]
70+ then
71+ echo "pow: Symlinking your app with pow. ${vhost}"
72+ [ ! -d ~/.pow/${vhost} ] && ln -s $basedir ~/.pow/$vhost
73+ return 1
74+ fi
75+}
76+
77+# View the standard out (puts) from any pow app
78+alias kaput="tail -f ~/Library/Logs/Pow/apps/*"