mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 21:51:42 +00:00
Cleaned up the plugins.
This commit is contained in:
20
plugins/pow/_pow
Normal file
20
plugins/pow/_pow
Normal file
@ -0,0 +1,20 @@
|
||||
#compdef pow-add pow-remove pow-restart
|
||||
#autoload
|
||||
|
||||
local ret=1
|
||||
|
||||
case "$service" in
|
||||
(pow-add)
|
||||
_arguments "1:application:_files -/" && ret=0
|
||||
;;
|
||||
(pow-(remove|restart))
|
||||
_arguments "1: :->pow-app" && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ "$state" == 'pow-app' ]]; then
|
||||
_arguments '1:application:($HOME/.pow/*(@N:t))' && ret=0
|
||||
fi
|
||||
|
||||
return "$ret"
|
||||
|
@ -1,10 +1,75 @@
|
||||
# Thanks to Christopher Sexton
|
||||
# https://gist.github.com/965032
|
||||
function kapow {
|
||||
touch ~/.pow/$1/tmp/restart.txt
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "$fg[yellow]Pow restarting $1...$reset_color"
|
||||
fi
|
||||
# Inspired by Christopher Sexton's
|
||||
# https://gist.github.com/1019777
|
||||
#
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
|
||||
# Gets the root of the Rack application.
|
||||
function _pow-rack-root() {
|
||||
local rack_root="${PWD}"
|
||||
|
||||
while [[ "${rack_root}" != '/' ]]; do
|
||||
# Rack applictions must have a config.ru file in the root directory.
|
||||
if [[ -f "${rack_root}/config.ru" ]]; then
|
||||
echo "${rack_root}"
|
||||
return 0
|
||||
else
|
||||
rack_root="${rack_root:h}"
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
compctl -W ~/.pow -/ kapow
|
||||
# Adds a Rack application to Pow.
|
||||
function pow-add() {
|
||||
local app="${${1:A}:-$(_pow-rack-root)}"
|
||||
local vhost="${app:t}"
|
||||
|
||||
if [[ ! -f "${app}/config.ru" ]]; then
|
||||
echo "${0}: ${vhost:-$PWD:t}: not a Rack application or config.ru is missing" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -L "${HOME}/.pow/${vhost}" ]]; then
|
||||
echo "${0}: ${vhost}: already served at http://${vhost}.dev"
|
||||
return 1
|
||||
fi
|
||||
|
||||
ln -s "${app}" "${HOME}/.pow/${vhost}"
|
||||
echo "Serving ${vhost} at http://${vhost}.dev"
|
||||
}
|
||||
|
||||
# Removes a Rack application from Pow.
|
||||
function pow-remove() {
|
||||
local symlink="${HOME}/.pow/${1}"
|
||||
if [[ -L "${symlink}" ]]; then
|
||||
unlink "${symlink}"
|
||||
echo "Stopped serving ${1}"
|
||||
else
|
||||
echo "${0}: ${1}: no such application" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Restarts a Rack application.
|
||||
function pow-restart() {
|
||||
local vhost="${${1}:-$(_pow-rack-root):t}"
|
||||
local tmp="${HOME}/.pow/${vhost}/tmp"
|
||||
|
||||
if [[ ! -L "${HOME}/.pow/${vhost}" ]]; then
|
||||
echo "${0}: ${1}: no such application" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "${tmp}" ]]; then
|
||||
mkdir -p "${tmp}"
|
||||
fi
|
||||
|
||||
if touch "${tmp}/restart.txt"; then
|
||||
echo "Restarted ${vhost}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Aliases
|
||||
# View the standard out (puts) from any pow application.
|
||||
alias pow-log="tail -f ${HOME}/Library/Logs/Pow/apps/*"
|
||||
|
||||
|
Reference in New Issue
Block a user