c1a04eb61fcdd740bef52cd9da75fd72aeac3cf4
- Author
- John Antoni Griffiths <john@johnantoni.com>
- Committer
- John Antoni Griffiths <john@johnantoni.com>
- Date
Message
take in csexton's changes
https://gist.github.com/1019777/70dbb46db9bd5b346faf543a9dd4edac4782adda
Diff
1diff --git a/plugins/pow/pow.plugin.zsh b/plugins/pow/pow.plugin.zsh
2index da94b657bfba701a07aa679adeb3ad90546167a2..08e5cf62fee1cbfc402fc88f288ec62e1435ee50 100644
3--- a/plugins/pow/pow.plugin.zsh
4+++ b/plugins/pow/pow.plugin.zsh
5@@ -4,7 +4,6 @@
6 # Adds a kapow command that will restart an app
7 #
8 # $ kapow myapp
9-# $ kapow # defaults to current directory
10 #
11 # Supports command completion.
12 #
13@@ -12,14 +11,40 @@
14 #
15 # autoload -U compinit compinit
16 #
17-# Thanks also to Christopher Sexton
18-# https://gist.github.com/965032
19+# Changes:
20 #
21-function kapow {
22- FOLDERNAME=$1
23- if [ -z "$FOLDERNAME" ]; then; FOLDERNAME=${PWD##*/}; fi
24- touch ~/.pow/$FOLDERNAME/tmp/restart.txt;
25- if [ $? -eq 0 ]; then; echo "pow: restarting $FOLDERNAME" ; fi
26+# Defaults to the current application, and will walk up the tree to find
27+# a config.ru file and restart the corresponding app
28+#
29+# Will Detect if a app does not exist in pow and print a (slightly) helpful
30+# error message
31+
32+rack_root_detect(){
33+ setopt chaselinks
34+ local orgdir=$(pwd)
35+ local basedir=$(pwd)
36+
37+ while [[ $basedir != '/' ]]; do
38+ test -e "$basedir/config.ru" && break
39+ builtin cd ".." 2>/dev/null
40+ basedir="$(pwd)"
41+ done
42+
43+ builtin cd $orgdir 2>/dev/null
44+ [[ ${basedir} == "/" ]] && return 1
45+ echo `basename $basedir | sed -E "s/.(com|net|org)//"`
46 }
47+kapow(){
48+ local vhost=$1
49+ [ ! -n "$vhost" ] && vhost=$(rack_root_detect)
50+ if [ ! -h ~/.pow/$vhost ]
51+ then
52+ echo "pow: This domain isn’t set up yet. Symlink your application to ${vhost} first."
53+ return 1
54+ fi
55
56-compctl -W ~/.pow -/ kapow
57+ [ ! -d "~/.pow/${vhost}/tmp" ] && mkdir -p "~/.pow/$vhost/tmp"
58+ touch ~/.pow/$vhost/tmp/restart.txt;
59+ [ $? -eq 0 ] && echo "pow: restarting $vhost.dev"
60+}
61+compctl -W ~/.pow -/ kapow