Commit 772bc51c authored by James Smith's avatar James Smith
Browse files

Merge

parents 0ba398f9 d05b2010
if [[ -x `which nc` ]]; then
alias nyan='nc -v miku.acm.uiuc.edu 23' # nyan cat
fi
...@@ -3,30 +3,43 @@ ...@@ -3,30 +3,43 @@
# pip zsh completion, based on homebrew completion # pip zsh completion, based on homebrew completion
_pip_all() {
# we cache the list of packages (originally from the macports plugin)
if (( ! $+piplist )); then
echo -n " (caching package index...)"
piplist=($(pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'))
fi
}
_pip_installed() { _pip_installed() {
installed_pkgs=(`pip freeze`) installed_pkgs=(`pip freeze | cut -d '=' -f 1`)
} }
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'bundle:Create pybundles (archives containing multiple packages)' 'bundle:create pybundles (archives containing multiple packages)'
'freeze:Output all currently installed packages (exact versions) to stdout' 'freeze:output all currently installed packages (exact versions) to stdout'
'help:Show available commands' 'help:show available commands'
'install:Install packages' 'install:install packages'
'search:Search PyPI' 'search:search PyPI'
'uninstall:Uninstall packages' 'uninstall:uninstall packages'
'unzip:Unzip individual packages' 'unzip:unzip individual packages'
'zip:Zip individual packages' 'zip:zip individual packages'
) )
local expl local expl
local -a pkgs installed_pkgs local -a all_pkgs installed_pkgs
_arguments \ _arguments \
'(--version)--version[Show version number of program and exit]' \ '(--version)--version[show version number of program and exit]' \
'(-v --verbose)'{-v,--verbose}'[Give more output]' \ '(-h --help)'{-h,--help}'[show help]' \
'(-q --quiet)'{-q,--quiet}'[Give less output]' \ '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \
'(-h --help)'{-h,--help}'[Show help]' \ '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \
'(-v --verbose)'{-v,--verbose}'[give more output]' \
'(-q --quiet)'{-q,--quiet}'[give less output]' \
'(--log)--log[log file location]' \
'(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
'(--timeout)--timeout[socket timeout (default 15s)]' \
'*:: :->subcmds' && return 0 '*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then if (( CURRENT == 1 )); then
...@@ -35,10 +48,25 @@ if (( CURRENT == 1 )); then ...@@ -35,10 +48,25 @@ if (( CURRENT == 1 )); then
fi fi
case "$words[1]" in case "$words[1]" in
list) search)
if [[ "$state" == forms ]]; then _arguments \
_pip_installed '(--index)--index[base URL of Python Package Index]' ;;
_requested installed_pkgs expl 'installed packages' compadd -a installed_pkgs freeze)
_arguments \
'(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
install)
_arguments \
'(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
'(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
'(--no-deps --no-dependencies)'{--no-deps,--no-dependencies}'[iIgnore package dependencies]' \
'(--no-install)--no-install[only download packages]' \
'(--no-download)--no-download[only install downloaded packages]' \
'(--install-option)--install-option[extra arguments to be supplied to the setup.py]' \
'1: :->packages' && return 0
if [[ "$state" == packages ]]; then
_pip_all
_wanted piplist expl 'packages' compadd -a piplist
fi ;; fi ;;
uninstall) uninstall)
_pip_installed _pip_installed
......
# Thanks to Christopher Sexton # Restart a rack app running under pow
# https://gist.github.com/965032 # http://pow.cx/
function kapow { #
touch ~/.pow/$1/tmp/restart.txt # Adds a kapow command that will restart an app
if [ $? -eq 0 ]; then #
echo "$fg[yellow]Pow restarting $1...$reset_color" # $ kapow myapp
fi #
# Supports command completion.
#
# If you are not already using completion you might need to enable it with
#
# autoload -U compinit compinit
#
# Changes:
#
# Defaults to the current application, and will walk up the tree to find
# a config.ru file and restart the corresponding app
#
# Will Detect if a app does not exist in pow and print a (slightly) helpful
# error message
rack_root_detect(){
setopt chaselinks
local orgdir=$(pwd)
local basedir=$(pwd)
while [[ $basedir != '/' ]]; do
test -e "$basedir/config.ru" && break
builtin cd ".." 2>/dev/null
basedir="$(pwd)"
done
builtin cd $orgdir 2>/dev/null
[[ ${basedir} == "/" ]] && return 1
echo `basename $basedir | sed -E "s/.(com|net|org)//"`
} }
kapow(){
local vhost=$1
[ ! -n "$vhost" ] && vhost=$(rack_root_detect)
if [ ! -h ~/.pow/$vhost ]
then
echo "pow: This domain isn’t set up yet. Symlink your application to ${vhost} first."
return 1
fi
[ ! -d ~/.pow/${vhost}/tmp ] && mkdir -p ~/.pow/$vhost/tmp
touch ~/.pow/$vhost/tmp/restart.txt;
[ $? -eq 0 ] && echo "pow: restarting $vhost.dev"
}
compctl -W ~/.pow -/ kapow compctl -W ~/.pow -/ kapow
powit(){
local basedir=$(pwd)
local vhost=$1
[ ! -n "$vhost" ] && vhost=$(rack_root_detect)
if [ ! -h ~/.pow/$vhost ]
then
echo "pow: Symlinking your app with pow. ${vhost}"
[ ! -d ~/.pow/${vhost} ] && ln -s $basedir ~/.pow/$vhost
return 1
fi
}
# View the standard out (puts) from any pow app
alias kaput="tail -f ~/Library/Logs/Pow/apps/*"
#compdef powder
#autoload
compadd `powder help | grep powder | cut -d " " -f 4`
# Find python file
alias pyfind='find . -name "*.py"'
# Remove python compiled byte-code
alias pyclean='find . -type f -name "*.py[co]" -delete'
# Grep among .py files
alias pygrep='grep --include="*.py"'
...@@ -2,6 +2,7 @@ alias ss='thin --stats "/thin/stats" start' ...@@ -2,6 +2,7 @@ alias ss='thin --stats "/thin/stats" start'
alias sg='ruby script/generate' alias sg='ruby script/generate'
alias sd='ruby script/destroy' alias sd='ruby script/destroy'
alias sp='ruby script/plugin' alias sp='ruby script/plugin'
alias sr='ruby script/runner'
alias ssp='ruby script/spec' alias ssp='ruby script/spec'
alias rdbm='rake db:migrate' alias rdbm='rake db:migrate'
alias sc='ruby script/console' alias sc='ruby script/console'
......
...@@ -13,7 +13,11 @@ alias rd='_rails_command destroy' ...@@ -13,7 +13,11 @@ alias rd='_rails_command destroy'
alias rdb='_rails_command dbconsole' alias rdb='_rails_command dbconsole'
alias rdbm='rake db:migrate db:test:clone' alias rdbm='rake db:migrate db:test:clone'
alias rg='_rails_command generate' alias rg='_rails_command generate'
alias rgm='_rails_command generate migration'
alias rp='_rails_command plugin' alias rp='_rails_command plugin'
alias ru='_rails_command runner'
alias rs='_rails_command server' alias rs='_rails_command server'
alias rsd='_rails_command server --debugger' alias rsd='_rails_command server --debugger'
alias devlog='tail -f log/development.log' alias devlog='tail -f log/development.log'
alias rdm='rake db:migrate'
alias rdr='rake db:rollback'
alias rake="noglob rake" # allows square brackts for rake task invocation
alias brake='noglob bundle exec rake' # execute the bundled rake gem
alias srake='noglob sudo rake' # noglob must come before sudo
alias sbrake='noglob sudo bundle exec rake' # altogether now ...
_homebrew-installed() {
type brew &> /dev/null
}
_rbenv-from-homebrew-installed() {
brew --prefix rbenv &> /dev/null
}
FOUND_RBENV=0
rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv")
if _homebrew-installed && _rbenv-from-homebrew-installed ; then
rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}")
fi
for rbenvdir in "${rbenvdirs[@]}" ; do
if [ -d $rbenvdir/bin -a $FOUND_RBENV -eq 0 ] ; then
FOUND_RBENV=1
export RBENV_ROOT=$rbenvdir
export PATH=${rbenvdir}/bin:$PATH
eval "$(rbenv init - zsh)"
alias rubies="rbenv versions"
alias gemsets="rbenv gemset list"
function current_ruby() {
echo "$(rbenv version-name)"
}
function current_gemset() {
echo "$(rbenv gemset active 2&>/dev/null | sed -e ":a" -e '$ s/\n/+/gp;N;b a' | head -n1)"
}
function gems {
local rbenv_path=$(rbenv prefix)
gem list $@ | sed \
-Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \
-Ee "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
}
function rbenv_prompt_info() {
if [[ -n $(current_gemset) ]] ; then
echo "$(current_ruby)@$(current_gemset)"
else
echo "$(current_ruby)"
fi
}
fi
done
unset rbenvdir
if [ $FOUND_RBENV -eq 0 ] ; then
alias rubies='ruby -v'
function gemsets() { echo 'not supported' }
function rbenv_prompt_info() { echo "system: $(ruby -v | cut -f-2 -d ' ')" }
fi
# Enables rbfu with --auto option, if available.
#
# Also provides a command to list all installed/available
# rubies. To ensure compatibility with themes, creates the
# rvm_prompt_info function to return the $RBFU_RUBY_VERSION
# version.
command -v rbfu &>/dev/null
if [[ $? -eq 0 ]]; then
eval "$(rbfu --init --auto)"
# Internal: Print ruby version details, if it's currently
# active etc.
function _rbfu_rubies_print() {
local rb rb_out
rb=$(basename $1)
rb_out="$rb"
[[ -h $1 ]] && rb_out="$rb_out${fg[green]}@${reset_color}"
[[ "x$rb" == "x$2" ]] && rb_out="${fg[red]}$rb_out ${fg[red]}*${reset_color}"
echo $rb_out
}
# Public: Provide a list with all available rubies, this basically depends
# on `ls -1` and .rfbu/rubies. Highlights the currently active ruby version
# and aliases.
function rbfu-rubies() {
local rbfu_dir active_rb
rbfu_dir=$RBFU_RUBIES
active_rb=$RBFU_RUBY_VERSION
[[ -z "$rbfu_dir" ]] && rbfu_dir="${HOME}/.rbfu/rubies"
[[ -z "$active_rb" ]] && active_rb="system"
_rbfu_rubies_print "${rbfu_dir}/system" $active_rb
for rb in $(ls -1 $rbfu_dir); do
_rbfu_rubies_print "${rbfu_dir}/${rb}" $active_rb
done
}
# Public: Create rvm_prompt_info command for themes compatibility, unless
# it has already been defined.
[ ! -x rvm_prompt_info ] && function rvm_prompt_info() { echo "${RBFU_RUBY_VERSION:=system}" }
fi
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
alias sgem='sudo gem' alias sgem='sudo gem'
# Find ruby file # Find ruby file
alias rfind='find . -name *.rb | xargs grep -n' alias rfind='find . -name "*.rb" | xargs grep -n'
...@@ -37,7 +37,7 @@ function gems { ...@@ -37,7 +37,7 @@ function gems {
local current_gemset=`rvm-prompt g` local current_gemset=`rvm-prompt g`
gem list $@ | sed \ gem list $@ | sed \
-Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \ -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
-Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
......
# if using GNU screen, let the zsh tell screen what the title and hardstatus
# of the tab window should be.
if [[ $TERM == "screen" ]]; then
if [[ $_GET_PATH == '' ]]; then
_GET_PATH='echo $PWD | sed "s/^\/Users\//~/;s/^\/home\//~/;s/^~$USER/~/"'
fi
if [[ $_GET_HOST == '' ]]; then
_GET_HOST='echo $HOST | sed "s/\..*//"'
fi
# use the current user as the prefix of the current tab title
TAB_TITLE_PREFIX='"`'$_GET_HOST'`:`'$_GET_PATH' | sed "s:..*/::"`$PROMPT_CHAR"'
# when at the shell prompt, show a truncated version of the current path (with
# standard ~ replacement) as the rest of the title.
TAB_TITLE_PROMPT='$SHELL:t'
# when running a command, show the title of the command as the rest of the
# title (truncate to drop the path to the command)
TAB_TITLE_EXEC='$cmd[1]:t'
# use the current path (with standard ~ replacement) in square brackets as the
# prefix of the tab window hardstatus.
TAB_HARDSTATUS_PREFIX='"[`'$_GET_PATH'`] "'
# when at the shell prompt, use the shell name (truncated to remove the path to
# the shell) as the rest of the title
TAB_HARDSTATUS_PROMPT='$SHELL:t'
# when running a command, show the command name and arguments as the rest of
# the title
TAB_HARDSTATUS_EXEC='$cmd'
# tell GNU screen what the tab window title ($1) and the hardstatus($2) should be
function screen_set()
{
# set the tab window title (%t) for screen
print -nR $'\033k'$1$'\033'\\\
# set hardstatus of tab window (%h) for screen
print -nR $'\033]0;'$2$'\a'
}
# called by zsh before executing a command
function preexec()
{
local -a cmd; cmd=(${(z)1}) # the command string
eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_EXEC"
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_EXEC"
screen_set $tab_title $tab_hardstatus
}
# called by zsh before showing the prompt
function precmd()
{
eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_PROMPT"
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_PROMPT"
screen_set $tab_title $tab_hardstatus
}
fi
\ No newline at end of file
# Contributed and SLIGHTLY modded by Matt Parnell/ilikenwf <parwok -at- gmail>
# Created by the blogger at the URL below...I don't know where to find his/her name
# Original found at http://www.shellperson.net/sprunge-pastebin-script/
usage() {
description | fmt -s >&2
}
description() {
cat << HERE
DESCRIPTION
Upload data and fetch URL from the pastebin http://sprunge.us
USAGE
$0 filename.txt
$0 text string
$0 < filename.txt
piped_data | $0
NOTES
--------------------------------------------------------------------------
* INPUT METHODS *
$0 can accept piped data, STDIN redirection [<filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code.
* PRECEDENCE *
STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as an arguments.
EXAMPLE:
echo piped | "$0" arguments.txt < stdin_redirection.txt
In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded.
* FILENAMES *
If a filename is misspelled or doesn't have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it.
--------------------------------------------------------------------------
HERE
exit
}
sprunge() {
if [ -t 0 ]; then
echo Running interactively, checking for arguments... >&2
if [ "$*" ]; then
echo Arguments present... >&2
if [ -f "$*" ]; then
echo Uploading the contents of "$*"... >&2
cat "$*"
else
echo Uploading the text: \""$*"\"... >&2
echo "$*"
fi | curl -F 'sprunge=<-' http://sprunge.us
else
echo No arguments found, printing USAGE and exiting. >&2
usage
fi
else
echo Using input from a pipe or STDIN redirection... >&2
while read -r line ; do
echo $line
done | curl -F 'sprunge=<-' http://sprunge.us
fi
}
# Sublime Text 2 Aliases
#unamestr = 'uname'
if [[ $('uname') == 'Linux' ]]; then
alias st='/usr/bin/sublime_text&'
elif [[ $('uname') == 'Darwin' ]]; then
alias st='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'
fi
alias stt='st .'
alias zi='sudo zypper install'
alias zrf='sudo zypper refresh'
alias zs='zypper search'
alias zup='sudo zypper dist-upgrade'
alias zrm='sudo zypper remove'
alias zp='sudo zypper patch'
alias zps='sudo zypper ps'
function svn_prompt_info { function svn_prompt_info {
if [ in_svn ]; then if [ $(in_svn) ]; then
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$(svn_get_repo_name)$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR" $ZSH_THEME_REPO_NAME_COLOR$(svn_get_repo_name)$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR"
fi fi
...@@ -13,21 +13,21 @@ function in_svn() { ...@@ -13,21 +13,21 @@ function in_svn() {
} }
function svn_get_repo_name { function svn_get_repo_name {
if [ in_svn ]; then if [ $(in_svn) ]; then
svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//" svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p"
fi fi
} }
function svn_get_rev_nr { function svn_get_rev_nr {
if [ in_svn ]; then if [ $(in_svn) ]; then
svn info 2> /dev/null | sed -n s/Revision:\ //p svn info 2> /dev/null | sed -n s/Revision:\ //p
fi fi
} }
function svn_dirty_choose { function svn_dirty_choose {
if [ in_svn ]; then if [ $(in_svn) ]; then
s=$(svn status|grep -E '^\s*[ACDIM!?L]' 2>/dev/null) s=$(svn status|grep -E '^\s*[ACDIM!?L]' 2>/dev/null)
if [ $s ]; then if [ $s ]; then
echo $1 echo $1
......
# Symfony2 basic command completion
_symfony2_get_command_list () {
app/console --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
}
_symfony2 () {
if [ -f app/console ]; then
compadd `_symfony2_get_command_list`
fi
}
compdef _symfony2 app/console
\ No newline at end of file
#compdef task #compdef task
#
# zsh completion for taskwarrior # zsh completion for taskwarrior
# #
# taskwarrior - a command line task list manager.
#
# Copyright 2010 - 2011 Johannes Schlatow # Copyright 2010 - 2011 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar # Copyright 2009 P.C. Shyamshankar
# All rights reserved.
#
# This script is part of the taskwarrior project.
# #
# This program is free software; you can redistribute it and/or modify it under # Permission is hereby granted, free of charge, to any person obtaining a copy
# the terms of the GNU General Public License as published by the Free Software # of this software and associated documentation files (the "Software"), to deal
# Foundation; either version 2 of the License, or (at your option) any later # in the Software without restriction, including without limitation the rights
# version. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# #
# This program is distributed in the hope that it will be useful, but WITHOUT # The above copyright notice and this permission notice shall be included
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # in all copies or substantial portions of the Software.
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
# #
# You should have received a copy of the GNU General Public License along with # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# this program; if not, write to the # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# #
# Free Software Foundation, Inc., # http://www.opensource.org/licenses/mit-license.php
# 51 Franklin Street, Fifth Floor,
# Boston, MA
# 02110-1301
# USA
# #
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects)) _task_projects=($(task _projects))
_task_tags=($(task _tags)) _task_tags=($(task _tags))
_task_ids=($(task _ids)) _task_ids=($(task _ids))
_task_config=($(task _config)) _task_config=($(task _config))
_task_columns=($(task _columns))
_task_modifiers=( _task_modifiers=(
'before' \ 'before' \
'after' \ 'after' \
...@@ -46,39 +46,19 @@ _task_modifiers=( ...@@ -46,39 +46,19 @@ _task_modifiers=(
'word' \ 'word' \
'noword' 'noword'
) )
_task_conjunctions=(
'and' \
'or' \
'xor' \
'\)'
'\('
)
_task_cmds=($(task _commands)) _task_cmds=($(task _commands))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} ) _task_zshcmds=( ${(f)"$(task _zshcommands)"} )
_task_idCmds=(
'append' \
'prepend' \
'annotate' \
'denotate' \
'edit' \
'duplicate' \
'info' \
'start' \
'stop' \
'done'
)
_task_idCmdsDesc=(
'append:Appends more description to an existing task.' \
'prepend:Prepends more description to an existing task.' \
'annotate:Adds an annotation to an existing task.' \
'denotate:Deletes an annotation of an existing task.' \
'edit:Launches an editor to let you modify a task directly.' \
'duplicate:Duplicates the specified task, and allows modifications.' \
'info:Shows all data, metadata for specified task.' \
'start:Marks specified task as started.' \
'stop:Removes the start time from a task.' \
'done:Marks the specified task as completed.'
)
_task() { _task() {
_arguments -s -S \ _arguments -s -S \
"*::task command:_task_commands" "*::task default:_task_default"
return 0 return 0
} }
...@@ -148,6 +128,7 @@ _regex_words values 'task frequencies' \ ...@@ -148,6 +128,7 @@ _regex_words values 'task frequencies' \
'weekly:Every week' \ 'weekly:Every week' \
'biweekly:Every two weeks' \ 'biweekly:Every two weeks' \
'fortnight:Every two weeks' \ 'fortnight:Every two weeks' \
+ 'monthly:Every month' \
'quarterly:Every three months' \ 'quarterly:Every three months' \
'semiannual:Every six months' \ 'semiannual:Every six months' \
'annual:Every year' \ 'annual:Every year' \
...@@ -196,22 +177,13 @@ _regex_arguments _task_attributes "${args[@]}" ...@@ -196,22 +177,13 @@ _regex_arguments _task_attributes "${args[@]}"
## task commands ## task commands
# default completion # filter completion
(( $+functions[_task_default] )) || (( $+functions[_task_filter] )) ||
_task_default() { _task_filter() {
_task_attributes "$@" _task_attributes "$@"
}
# commands expecting an ID # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
(( $+functions[_task_id] )) || _describe -t default 'task conjunctions' _task_conjunctions
_task_id() {
if (( CURRENT < 3 )); then
# update IDs
_task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t values 'task IDs' _task_zshids
else
_task_attributes "$@"
fi
} }
# merge completion # merge completion
...@@ -235,46 +207,42 @@ _task_pull() { ...@@ -235,46 +207,42 @@ _task_pull() {
_files _files
} }
# execute completion
(( $+functions[_task_execute] )) ||
_task_execute() {
_files
}
# modify (task [0-9]* ...) completion # id-only completion
(( $+functions[_task_modify] )) || (( $+functions[_task_id] )) ||
_task_modify() { _task_id() {
_describe -t commands 'task command' _task_idCmdsDesc _describe -t values 'task IDs' _task_zshids
_task_attributes "$@"
} }
## first level completion => task sub-command completion ## first level completion => task sub-command completion
(( $+functions[_task_commands] )) || (( $+functions[_task_default] )) ||
_task_commands() { _task_default() {
local cmd ret=1 local cmd ret=1
if (( CURRENT == 1 )); then
integer i=1
while (( i < $#words ))
do
cmd="${_task_cmds[(r)$words[$i]]}"
if (( $#cmd )); then
_call_function ret _task_${cmd} ||
_call_function ret _task_filter ||
_message "No command remaining."
return ret
fi
(( i++ ))
done
# update IDs # update IDs
_task_zshids=( ${(f)"$(task _zshids)"} ) _task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t commands 'task command' _task_zshcmds _describe -t commands 'task command' _task_zshcmds
_describe -t values 'task IDs' _task_zshids _describe -t values 'task IDs' _task_zshids
# TODO match more than one ID _call_function ret _task_filter
elif [[ $words[1] =~ ^[0-9]*$ ]] then
_call_function ret _task_modify
return ret
else
# local curcontext="${curcontext}"
# cmd="${_task_cmds[(r)$words[1]:*]%%:*}"
cmd="${_task_cmds[(r)$words[1]]}"
idCmd="${(M)_task_idCmds[@]:#$words[1]}"
if (( $#cmd )); then
# curcontext="${curcontext%:*:*}:task-${cmd}"
if (( $#idCmd )); then
_call_function ret _task_id
else
_call_function ret _task_${cmd} ||
_call_function ret _task_default ||
_message "No command remaining."
fi
else
_message "Unknown subcommand ${cmd}"
fi
return ret return ret
fi
} }
# Set Apple Terminal.app resume directory
# based on this answer: http://superuser.com/a/315029
function chpwd {
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
chpwd
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment