Commit e4fdb083 authored by Andrew Janke's avatar Andrew Janke
Browse files

Merge branch 'master' into copyfile-portability

parents 5c8b0cc0 b05ef103
......@@ -54,10 +54,12 @@ alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
alias rdmtc='rake db:migrate db:test:clone'
alias rlc='rake log:clear'
alias rn='rake notes'
alias rr='rake routes'
alias rrg='rake routes | grep'
alias rt='rake test'
# legacy stuff
alias sstat='thin --stats "/thin/stats" start'
......
......@@ -18,8 +18,6 @@ if [[ -x `which curl` ]]; then
W=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
if [ "$W" -a "$TXT" ]; then
echo "${WHO_COLOR}${W}${COLON_COLOR}: ${TEXT_COLOR}${TXT}${END_COLOR}"
else
quote
fi
}
#quote
......
......@@ -2,14 +2,11 @@ _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" "/usr/local/opt/rbenv")
if _homebrew-installed && _rbenv-from-homebrew-installed ; then
rbenvdirs=($(brew --prefix rbenv) "${rbenvdirs[@]}")
if _homebrew-installed && rbenv_homebrew_path=$(brew --prefix rbenv 2>/dev/null); then
rbenvdirs=($rbenv_homebrew_path "${rbenvdirs[@]}")
unset rbenv_homebrew_path
fi
for rbenvdir in "${rbenvdirs[@]}" ; do
......
......@@ -61,11 +61,11 @@ function gems {
local current_ruby=`rvm-prompt i v p`
local current_gemset=`rvm-prompt g`
gem list $@ | sed \
-Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$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$current_gemset$/$fg[green]&$reset_color/g"
gem list $@ | sed -E \
-e "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
-e "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
-e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
-e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"
}
function _rvm_completion {
......
## Scaleway CLI autocomplete plugin
[scw](https://github.com/scaleway/scaleway-cli): Manage Bare Metal servers from Command Line (as easily as with Docker)
- Adds autocomplete options for all `scw` commands.
Maintainer : Manfred Touron ([@moul](https://github.com/moul))
#compdef scw
#
# zsh completion for scw (http://scaleway.com)
#
# Inspired by https://github.com/felixr/docker-zsh-completion
__scw_get_servers() {
local expl
declare -a servers
servers=(${(f)"$(_call_program commands scw _completion servers-names)"})
_describe -t servers "servers" servers
}
__scw_stoppedservers() {
__scw_get_servers
}
__scw_runningservers() {
__scw_get_servers
}
__scw_servers () {
__scw_get_servers
}
__scw_images () {
local expl
declare -a images
images=(${(f)"$(_call_program commands scw _completion images-names)"})
_describe -t images "images" images
}
__scw_images_and_snapshots () {
__scw_images
__scw_snapshots
}
__scw_snapshots () {
local expl
declare -a snapshots
snapshots=(${(f)"$(_call_program commands scw _completion --prefix snapshots-names)"})
_describe -t snapshots "snapshots" snapshots
}
__scw_bootscripts () {
local expl
declare -a bootscripts
bootscripts=(${(f)"$(_call_program commands scw _completion bootscripts-names)"})
_describe -t bootscripts "bootscripts" bootscripts
}
__scw_tags() {
__scw_images
}
__scw_repositories_with_tags() {
__scw_images
}
__scw_search() {
# declare -a scwsearch
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
fi
local searchterm cachename
searchterm="${words[$CURRENT]%/}"
cachename=_scw-search-$searchterm
local expl
local -a result
if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
&& ! _retrieve_cache ${cachename#_}; then
_message "Searching for ${searchterm}..."
result=(${${${(f)"$(_call_program commands scw search ${searchterm})"}%% *}[2,-1]})
_store_cache ${cachename#_} result
fi
_wanted scwsearch expl 'available images' compadd -a result
}
__scw_caching_policy()
{
oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
}
__scw_repositories () {
__scw_images
}
__scw_commands () {
# local -a _scw_subcommands
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
fi
if ( [[ ${+_scw_subcommands} -eq 0 ]] || _cache_invalid scw_subcommands) \
&& ! _retrieve_cache scw_subcommands;
then
local -a lines
lines=(${(f)"$(_call_program commands scw 2>&1)"})
_scw_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
_scw_subcommands=($_scw_subcommands 'help:Show help for a command')
_store_cache scw_subcommands _scw_subcommands
fi
_describe -t scw-commands "scw command" _scw_subcommands
}
__scw_subcommand () {
local -a _command_args
case "$words[1]" in
(attach)
_arguments \
'--no-stdin[Do not attach stdin]' \
':servers:__scw_runningservers'
;;
(commit)
_arguments \
{-v,--volume=0}'[Volume slot]:volume: ' \
':server:__scw_servers' \
':repository:__scw_repositories_with_tags'
;;
(cp)
_arguments \
':server:->server' \
':hostpath:_files'
case $state in
(server)
if compset -P '*:'; then
_files
else
__scw_servers -qS ":"
fi
;;
esac
;;
(exec)
local state ret
_arguments \
{-T,--timeout=0}'[Set timeout values to seconds]' \
{-w,--wait}'[Wait for SSH to be ready]' \
':servers:__scw_runningservers' \
'*::command:->anycommand' && ret=0
case $state in
(anycommand)
shift 1 words
(( CURRENT-- ))
_normal
;;
esac
return ret
;;
(history)
_arguments \
'--no-trunc[Do not truncate output]' \
{-q,--quiet}'[Only show numeric IDs]' \
'*:images:__scw_images'
;;
(images)
_arguments \
{-a,--all}'[Show all images]' \
'--no-trunc[Do not truncate output]' \
{-q,--quiet}'[Only show numeric IDs]' \
':repository:__scw_repositories'
;;
(info)
;;
(inspect)
_arguments \
{-f,--format=-}'[Format the output using the given go template]:template: ' \
'*:servers:__scw_servers'
;;
(kill)
_arguments \
'*:servers:__scw_runningservers'
;;
(login)
_arguments \
{-o,--organization=-}'[Organization]:organization: ' \
{-t,--token=-}'[Token]:token: ' \
':server: '
;;
(logout)
_arguments \
':server: '
;;
(logs)
_arguments \
'*:servers:__scw_servers'
;;
(port)
_arguments \
'1:servers:__scw_runningservers' \
'2:port:_ports'
;;
(start)
_arguments \
{-T,--timeout=0}'[Set timeout values to seconds]' \
{-w,--wait}'[Wait for SSH to be ready]' \
'*:servers:__scw_stoppedservers'
;;
(rm)
_arguments \
'*:servers:__scw_stoppedservers'
;;
(rmi)
_arguments \
'*:images:__scw_images'
;;
(restart)
_arguments \
'*:servers:__scw_runningservers'
;;
(stop)
_arguments \
{-t,--terminate}'[Stop and trash a server with its volumes]' \
{-w,--wait}'[Synchronous stop. Wait for server to be stopped]' \
'*:servers:__scw_runningservers'
;;
(top)
_arguments \
'1:servers:__scw_runningservers' \
'(-)*:: :->ps-arguments'
case $state in
(ps-arguments)
_ps
;;
esac
;;
(ps)
_arguments \
{-a,--all}'[Show all servers. Only running servers are shown by default]' \
{-l,--latest}'[Show only the latest created server]' \
'-n[Show n last created servers, include non-running one]:n:(1 5 10 25 50)' \
'--no-trunc[Do not truncate output]' \
{-q,--quiet}'[Only show numeric IDs]'
;;
(tag)
_arguments \
{-f,--force}'[force]'\
':image:__scw_images'\
':repository:__scw_repositories_with_tags'
;;
(create|run)
_arguments \
{-a,--attach}'[Attach to stdin, stdout or stderr]' \
'*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \
'--name=-[Server name]:name: ' \
'--bootscript=-[Assign a bootscript]:bootscript:__scw_bootscripts ' \
'*-v[Bind mount a volume]:volume: '\
'(-):images:__scw_images_and_snapshots' \
'(-):command: _command_names -e' \
'*::arguments: _normal'
case $state in
(link)
if compset -P '*:'; then
_wanted alias expl 'Alias' compadd -E ""
else
__scw_runningservers -qS ":"
fi
;;
esac
;;
(rename)
_arguments \
':old name:__scw_servers' \
':new name: '
;;
(search)
_arguments \
'--no-trunc[Do not truncate output]' \
':term: '
;;
(wait)
_arguments '*:servers:__scw_runningservers'
;;
(help)
_arguments ':subcommand:__scw_commands'
;;
(*)
_message 'Unknown sub command'
esac
}
_scw () {
# Support for subservices, which allows for `compdef _scw scw-shell=_scw_servers`.
# Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
if [[ $service != scw ]]; then
_call_function - _$service
return
fi
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
'-H[tcp://host:port to bind/connect to]:socket: ' \
'(-): :->command' \
'(-)*:: :->option-or-argument'
if (( CURRENT == 1 )); then
fi
case $state in
(command)
__scw_commands
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:scw-$words[1]:
__scw_subcommand
;;
esac
}
_scw "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 4
# indent-tabs-mode: nil
# sh-basic-offset: 4
# End:
# vim: ft=zsh sw=4 ts=4 et
# Spring Boot oh-my-zsh plugin
oh-my-zsh Spring Boot plugin
## Spring Boot autocomplete plugin
- Adds autocomplete options for all spring boot commands.
## Manual Install
$ cd ~/.oh-my-zsh/plugins
$ git clone git@github.com:linux-china/oh-my-zsh-spring-boot-plugin.git spring
Adjust your .zshrc file and add spring to plugins=(...)
## Tips
* Install Spring Cloud plugin: spring install org.springframework.cloud:spring-cloud-cli:1.0.2.RELEASE
## Reference
* Spring Boot: http://projects.spring.io/spring-boot/
* Spring Boot CLI: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#cli
Maintainer : linux_china ([@linux_china](https://twitter.com/linux_china))
#compdef spring 'spring'
#autoload
_spring() {
local cword
let cword=CURRENT-1
local hints
hints=()
local reply
while read -r line; do
reply=`echo "$line" | awk '{printf $1 ":"; for (i=2; i<NF; i++) printf $i " "; print $NF}'`
hints+=("$reply")
done < <(spring hint ${cword} ${words[*]})
if ((cword == 1)) {
_describe -t commands 'commands' hints
return 0
}
_describe -t options 'options' hints
_files
return 0
}
_spring "$@"
\ No newline at end of file
function _stack_commands() {
local ret=1 state
_arguments ':subcommand:->subcommand' && ret=0
case $state in
subcommand)
subcommands=(
"build:Build the project(s) in this directory/configuration"
"install:Build executables and install to a user path"
"test:Build and test the project(s) in this directory/configuration"
"bench:Build and benchmark the project(s) in this directory/configuration"
"haddock:Generate haddocks for the project(s) in this directory/configuration"
"new:Create a brand new project"
"init:Initialize a stack project based on one or more stack packages"
"solver:Use a dependency solver to try and determine missing extra-deps"
"setup:Get the appropriate ghc for your project"
"path:Print out handy path information"
"unpack:Unpack one or more packages locally"
"update:Update the package index"
"upgrade:Upgrade to the latest stack (experimental)"
"upload:Upload a package to Hackage"
"dot:Visualize your project's dependency graph using Graphviz dot"
"exec:Execute a command"
"ghc:Run ghc"
"ghci:Run ghci in the context of project(s)"
"ide:Run ide-backend-client with the correct arguments"
"runghc:Run runghc"
"clean:Clean the local packages"
"docker:Subcommands specific to Docker use"
)
_describe -t subcommands 'stack subcommands' subcommands && ret=0
esac
return ret
}
compdef _stack_commands stack
# Sublime Text 2 Aliases
if [[ $('uname') == 'Linux' ]]; then
local _sublime_linux_paths > /dev/null 2>&1
_sublime_linux_paths=(
......@@ -33,7 +31,6 @@ elif [[ "$OSTYPE" = darwin* ]]; then
"$HOME/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl"
"$HOME/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"
)
for _sublime_path in $_sublime_darwin_paths; do
if [[ -a $_sublime_path ]]; then
subl () { "$_sublime_path" $* }
......@@ -43,4 +40,18 @@ elif [[ "$OSTYPE" = darwin* ]]; then
done
fi
elif [[ "$OSTYPE" = 'cygwin' ]]; then
local _sublime_cygwin_paths > /dev/null 2>&1
_sublime_cygwin_paths=(
"$(cygpath $ProgramW6432/Sublime\ Text\ 2)/sublime_text.exe"
"$(cygpath $ProgramW6432/Sublime\ Text\ 3)/sublime_text.exe"
)
for _sublime_path in $_sublime_cygwin_paths; do
if [[ -a $_sublime_path ]]; then
subl () { "$_sublime_path" $* }
alias st=subl
break
fi
done
alias stt='st .'
......@@ -14,7 +14,11 @@
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
[[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
if [[ $BUFFER == sudo\ * ]]; then
LBUFFER="${LBUFFER#sudo }"
else
LBUFFER="sudo $LBUFFER"
fi
}
zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
......
# vim:ft=zsh ts=2 sw=2 sts=2
#
function svn_prompt_info() {
local _DISPLAY
if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name)
else
_DISPLAY=$(svn_get_repo_name)
_DISPLAY=$(omz_urldecode "${_DISPLAY}")
fi
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
unset _DISPLAY
fi
}
......@@ -30,7 +31,7 @@ function svn_get_repo_name() {
}
function svn_get_branch_name() {
_DISPLAY=$(
local _DISPLAY=$(
svn info 2> /dev/null | \
awk -F/ \
'/^URL:/ { \
......@@ -49,7 +50,6 @@ function svn_get_branch_name() {
else
echo $_DISPLAY
fi
unset _DISPLAY
}
function svn_get_rev_nr() {
......@@ -60,7 +60,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() {
if in_svn; then
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
......@@ -77,7 +77,7 @@ function svn_dirty() {
function svn_dirty_choose_pwd () {
if in_svn; then
root=$PWD
local root=$PWD
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
......
......@@ -5,7 +5,7 @@ _symfony_console () {
}
_symfony2_get_command_list () {
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }'
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[^ ]+ / { print $1 }'
}
_symfony2 () {
......
......@@ -140,12 +140,16 @@ d0() {
# gather external ip address
geteip() {
curl http://ifconfig.me
curl -s -S https://icanhazip.com
}
# determine local IP address
getip() {
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
if (( ${+commands[ip]} )); then
ip addr | grep "inet " | grep -v '127.0.0.1' | awk '{print $2}'
else
ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'
fi
}
# Clear zombie processes
......
# taskwarrior
This plugin adds smart tab completion for [TaskWarrior](http://taskwarrior.org/).
It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the
completion definitions.
The latest version pulled in from the official project is of January 1st, 2015.
## Examples
Typing `task [TAB]` will give you a list of commands, `task 66[TAB]` shows a
list of available modifications for that task, etcetera.
#compdef task
# zsh completion for taskwarrior
#
# taskwarrior - a command line task list manager.
#
# Copyright 2010 - 2011 Johannes Schlatow
# Copyright 2010 - 2015 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
......@@ -30,31 +27,40 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects))
_task_tags=($(task _tags))
_task_ids=($(task _ids))
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
_task_columns=($(task _columns))
_task_modifiers=(
'before' \
'after' \
'none' \
'any' \
'is' \
'isnt' \
'has' \
'hasnt' \
'startswith' \
'endswith' \
'word' \
'noword'
'before' \
'after' \
'none' \
'any' \
'is' \
'isnt' \
'has' \
'hasnt' \
'startswith' \
'endswith' \
'word' \
'noword'
)
_task_conjunctions=(
'and' \
'or' \
'xor' \
'\)'
'\('
'and' \
'or' \
'xor' \
'\)' \
'\(' \
'<' \
'<=' \
'=' \
'!=' \
'>=' \
'>'
)
_task_cmds=($(task _commands))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
_task_cmds=($(task _commands; task _aliases))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel )
_task_aliases=($(task _aliases))
_task() {
_arguments -s -S \
......@@ -68,110 +74,130 @@ word=$'[^\0]#\0'
# priorities
local -a task_priorities
_regex_words values 'task priorities' \
'H:High' \
'M:Middle' \
'L:Low'
'H:High' \
'M:Middle' \
'L:Low'
task_priorities=("$reply[@]")
# projects
local -a task_projects
task_projects=(
/"$word"/
":values:task projects:compadd -a _task_projects"
/"$word"/
":values:task projects:compadd -a _task_projects"
)
local -a _task_dates
_regex_words values 'task dates' \
'tod*ay:Today' \
'yes*terday:Yesterday' \
'tom*orrow:Tomorrow' \
'sow:Start of week' \
'soww:Start of work week' \
'socw:Start of calendar week' \
'som:Start of month' \
'soy:Start of year' \
'eow:End of week' \
'eoww:End of work week' \
'eocw:End of calendar week' \
'eom:End of month' \
'eoy:End of year' \
'mon:Monday' \
'tue:Tuesday'\
'wed:Wednesday' \
'thu:Thursday' \
'fri:Friday' \
'sat:Saturday' \
'sun:Sunday'
'tod*ay:Today' \
'yes*terday:Yesterday' \
'tom*orrow:Tomorrow' \
'sow:Start of week' \
'soww:Start of work week' \
'socw:Start of calendar week' \
'som:Start of month' \
'soq:Start of quarter' \
'soy:Start of year' \
'eow:End of week' \
'eoww:End of work week' \
'eocw:End of calendar week' \
'eom:End of month' \
'eoq:End of quarter' \
'eoy:End of year' \
'mon:Monday' \
'tue:Tuesday'\
'wed:Wednesday' \
'thu:Thursday' \
'fri:Friday' \
'sat:Saturday' \
'sun:Sunday' \
'good*friday:Good Friday' \
'easter:Easter' \
'eastermonday:Easter Monday' \
'ascension:Ascension' \
'pentecost:Pentecost' \
'midsommar:Midsommar' \
'midsommarafton:Midsommarafton' \
'later:Later' \
'someday:Some Day'
_task_dates=("$reply[@]")
local -a _task_reldates
_regex_words values 'task reldates' \
'hrs:n hours' \
'day:n days' \
'1st:first' \
'2nd:second' \
'3rd:third' \
'th:4th, 5th, etc.' \
'wks:weeks'
'hrs:n hours' \
'day:n days' \
'1st:first' \
'2nd:second' \
'3rd:third' \
'th:4th, 5th, etc.' \
'wks:weeks'
_task_reldates=("$reply[@]")
task_dates=(
\( "$_task_dates[@]" \|
\( "$_task_dates[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \)
\)
\)
)
local -a task_zshids
_regex_words values 'task IDs' $_task_zshids
task_zshids=("$reply[@]")
_regex_words values 'task frequencies' \
'daily:Every day' \
'day:Every day' \
'weekdays:Every day skipping weekend days' \
'weekly:Every week' \
'biweekly:Every two weeks' \
'fortnight:Every two weeks' \
+ 'monthly:Every month' \
'quarterly:Every three months' \
'semiannual:Every six months' \
'annual:Every year' \
'yearly:Every year' \
'biannual:Every two years' \
'biyearly:Every two years'
'daily:Every day' \
'day:Every day' \
'weekdays:Every day skipping weekend days' \
'weekly:Every week' \
'biweekly:Every two weeks' \
'fortnight:Every two weeks' \
'monthly:Every month' \
'quarterly:Every three months' \
'semiannual:Every six months' \
'annual:Every year' \
'yearly:Every year' \
'biannual:Every two years' \
'biyearly:Every two years'
_task_freqs=("$reply[@]")
local -a _task_frequencies
_regex_words values 'task frequencies' \
'd:days' \
'w:weeks' \
'q:quarters' \
'y:years'
'd:days' \
'w:weeks' \
'q:quarters' \
'y:years'
_task_frequencies=("$reply[@]")
task_freqs=(
\( "$_task_freqs[@]" \|
\( "$_task_freqs[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \)
\)
\)
)
# attributes
local -a task_attributes
_regex_words -t ':' default 'task attributes' \
'pro*ject:Project name:$task_projects' \
'du*e:Due date:$task_dates' \
'wa*it:Date until task becomes pending:$task_dates' \
're*cur:Recurrence frequency:$task_freqs' \
'pri*ority:priority:$task_priorities' \
'un*til:Recurrence end date:$task_dates' \
'fg:Foreground color' \
'bg:Background color' \
'li*mit:Desired number of rows in report'
'des*cription:Task description text' \
'status:Status of task - pending, completed, deleted, waiting' \
'pro*ject:Project name:$task_projects' \
'pri*ority:priority:$task_priorities' \
'du*e:Due date:$task_dates' \
're*cur:Recurrence frequency:$task_freqs' \
'un*til:Expiration date:$task_dates' \
'li*mit:Desired number of rows in report' \
'wa*it:Date until task becomes pending:$task_dates' \
'ent*ry:Date task was created:$task_dates' \
'end:Date task was completed/deleted:$task_dates' \
'st*art:Date task was started:$task_dates' \
'sc*heduled:Date task is scheduled to start:$task_dates' \
'dep*ends:Other tasks that this task depends upon:$task_zshids'
task_attributes=("$reply[@]")
args=(
\( "$task_attributes[@]" \|
\( /'(project|due|wait|recur|priority|until|fg|bg|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
\( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
\( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
\( /"$word"/ \)
\) \#
\( "$task_attributes[@]" \|
\( /'(project|description|status|entry|end|start|scheduled|depends|due|wait|recur|priority|until|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
\( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
\( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
\( /"$word"/ \)
\) \#
)
_regex_arguments _task_attributes "${args[@]}"
......@@ -180,43 +206,50 @@ _regex_arguments _task_attributes "${args[@]}"
# filter completion
(( $+functions[_task_filter] )) ||
_task_filter() {
_task_attributes "$@"
# TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
_describe -t default 'task conjunctions' _task_conjunctions
}
# merge completion
(( $+functions[_task_merge] )) ||
_task_merge() {
# TODO match URIs in .taskrc
_files
}
# push completion
(( $+functions[_task_push] )) ||
_task_push() {
# TODO match URIs in .taskrc
_files
}
_task_attributes "$@"
# pull completion
(( $+functions[_task_pull] )) ||
_task_pull() {
# TODO match URIs in .taskrc
_files
# TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
_describe -t default 'task conjunctions' _task_conjunctions
}
# execute completion
(( $+functions[_task_execute] )) ||
_task_execute() {
_files
_files
}
# id-only completion
(( $+functions[_task_id] )) ||
_task_id() {
_describe -t values 'task IDs' _task_zshids
_describe -t values 'task IDs' _task_zshids
}
# subcommand-only function
(( $+functions[_task_subcommands] )) ||
_task_subcommands() {
local -a subcommands
local _zshcmd
local cmd category desc
local lastcategory=''
# The list is sorted by category, in the right order.
for _zshcmd in "$_task_zshcmds[@]"; do
# Parse out the three fields
cmd=${_zshcmd%%:*}
category=${${_zshcmd#*:}%%:*}
desc=${_zshcmd#*:*:}
# Present each category as soon as the first entry in the *next* category
# is seen.
if [[ $category != $lastcategory && -n $lastcategory ]]; then
_describe -t ${lastcategory}-commands "task ${lastcategory} command" subcommands
subcommands=()
fi
# Log the subcommand; we will process it in some future iteration.
subcommands+=( "$cmd:$desc" )
lastcategory=$category
done
}
## first level completion => task sub-command completion
......@@ -224,27 +257,28 @@ _task_id() {
_task_default() {
local cmd ret=1
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
_task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t commands 'task command' _task_zshcmds
_describe -t values 'task IDs' _task_zshids
_call_function ret _task_filter
return ret
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
_task_zshids=( ${(f)"$(task _zshids)"} )
_task_subcommands
_describe -t tasks 'task IDs' _task_zshids
_describe -t aliases 'task aliases' _task_aliases
_call_function ret _task_filter
return ret
}
_task
_task "$@"
################################################################################
# Author: Pete Clark
# Email: pete[dot]clark[at]gmail[dot]com
# Version: 0.1 (05/24/2011)
# License: WTFPL<http://sam.zoy.org/wtfpl/>
#
# This oh-my-zsh plugin adds smart tab completion for
# TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion
# script (_task) distributed with TaskWarrior for the completion definitions.
#
# Typing task [tabtab] will give you a list of current tasks, task 66[tabtab]
# gives a list of available modifications for that task, etc.
################################################################################
zstyle ':completion:*:*:task:*' verbose yes
zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'
......
# Set Apple Terminal.app resume directory
# based on this answer: http://superuser.com/a/315029
# 2012-10-26: (javageek) Changed code using the updated answer
# Tell the terminal about the working directory whenever it changes.
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
update_terminal_cwd() {
# Identify the directory using a "file:" scheme URL, including
# the host name to disambiguate local vs. remote paths.
# Percent-encode the pathname.
local URL_PATH=''
{
# Use LANG=C to process text byte-by-byte.
local i ch hexch LANG=C
for ((i = 1; i <= ${#PWD}; ++i)); do
ch="$PWD[i]"
if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
URL_PATH+="$ch"
else
hexch=$(printf "%02X" "'$ch")
URL_PATH+="%$hexch"
fi
done
}
local PWD_URL="file://$HOST$URL_PATH"
#echo "$PWD_URL" # testing
printf '\e]7;%s\a' "$PWD_URL"
}
# Register the function so it is called whenever the working
# directory changes.
autoload add-zsh-hook
add-zsh-hook precmd update_terminal_cwd
# Tell the terminal about the initial directory.
update_terminal_cwd
fi
# This file is intentionally empty.
#
# The terminalapp plugin is deprecated and may be removed in a future release.
# Its functionality has been folded in to the core lib/termsupport.zsh, which
# is loaded for all users. You can remove terminalapp from your $plugins list
# once all your systems are updated to the current version of Oh My Zsh.
# The Fuck
[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
## Usage
Press `ESC` twice to correct previous console command.
## Notes
`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin.
if [[ -z $commands[thefuck] ]]; then
echo 'thefuck is not installed, you should "pip install thefuck" first'
return -1
fi
# Register alias
eval "$(thefuck --alias)"
fuck-command-line() {
local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
[[ -z $FUCK ]] && echo -n -e "\a" && return
BUFFER=$FUCK
zle end-of-line
}
zle -N fuck-command-line
# Defined shortcut keys: [Esc] [Esc]
bindkey "\e\e" fuck-command-line
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