From 6a2e04fefbd794f050d45e7a717d009e39204431 Mon Sep 17 00:00:00 2001 From: clutton Date: Mon, 16 Jul 2012 02:59:30 +0300 Subject: [PATCH 1/6] =?UTF-8?q?modify=20themes/jnrowe.zsh-theme,=20add=20h?= =?UTF-8?q?ost=20directive=20"=CE=9E=20(mbsd)=20~=20=E2=86=92"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/jnrowe.zsh-theme | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/themes/jnrowe.zsh-theme b/themes/jnrowe.zsh-theme index 7c8a7082e..0ade9cc60 100644 --- a/themes/jnrowe.zsh-theme +++ b/themes/jnrowe.zsh-theme @@ -1,3 +1,4 @@ +autoload -U colors && colors autoload -U add-zsh-hook autoload -Uz vcs_info @@ -8,9 +9,10 @@ zstyle ':vcs_info:*' formats \ zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' zstyle ':vcs_info:*' enable git -add-zsh-hook precmd prompt_jnrowe_precmd +add-zsh-hook precmd prompt_vcs +add-zsh-hook precmd prompt_host -prompt_jnrowe_precmd () { +prompt_vcs () { vcs_info if [ "${vcs_info_msg_0_}" = "" ]; then @@ -24,8 +26,17 @@ prompt_jnrowe_precmd () { fi } +prompt_host () { + if [[ -n "$SSH_CLIENT" ]]; then + host=" ($HOST)" + else + host='' + fi +} + + local ret_status="%(?:%{$fg_bold[green]%}Ξ:%{$fg_bold[red]%}%S↑%s%?)" -PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} ' +PROMPT='${ret_status}%{$fg[blue]%}${host}%{$fg_bold[green]%}%p %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} ' # vim: set ft=zsh ts=4 sw=4 et: From d5bfbf05d16634fa3c2834c7097edb1cf2487d96 Mon Sep 17 00:00:00 2001 From: clutton Date: Tue, 24 Jul 2012 05:36:18 +0300 Subject: [PATCH 2/6] improvement: define PROMPT_HOST once on startup --- themes/jnrowe.zsh-theme | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/themes/jnrowe.zsh-theme b/themes/jnrowe.zsh-theme index 0ade9cc60..a1478be31 100644 --- a/themes/jnrowe.zsh-theme +++ b/themes/jnrowe.zsh-theme @@ -1,16 +1,14 @@ -autoload -U colors && colors autoload -U add-zsh-hook autoload -Uz vcs_info +zstyle ':vcs_info:*' disable-patterns "/usr/(ports|src)(|/*)" zstyle ':vcs_info:*' actionformats \ - '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' -zstyle ':vcs_info:*' formats \ - '%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f ' + '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' +zstyle ':vcs_info:*' formats '%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f ' zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' zstyle ':vcs_info:*' enable git add-zsh-hook precmd prompt_vcs -add-zsh-hook precmd prompt_host prompt_vcs () { vcs_info @@ -26,17 +24,16 @@ prompt_vcs () { fi } -prompt_host () { +function { if [[ -n "$SSH_CLIENT" ]]; then - host=" ($HOST)" + PROMPT_HOST=" ($HOST)" else - host='' + PROMPT_HOST='' fi } - local ret_status="%(?:%{$fg_bold[green]%}Ξ:%{$fg_bold[red]%}%S↑%s%?)" -PROMPT='${ret_status}%{$fg[blue]%}${host}%{$fg_bold[green]%}%p %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} ' +PROMPT='${ret_status}%{$fg[blue]%}${PROMPT_HOST}%{$fg_bold[green]%}%p %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} ' # vim: set ft=zsh ts=4 sw=4 et: From decb9c82b5392d66e157ceef9c3b41466bdcbafd Mon Sep 17 00:00:00 2001 From: clutton Date: Tue, 24 Jul 2012 14:16:03 +0300 Subject: [PATCH 3/6] delete os specific disable-patterns --- themes/jnrowe.zsh-theme | 1 - 1 file changed, 1 deletion(-) diff --git a/themes/jnrowe.zsh-theme b/themes/jnrowe.zsh-theme index a1478be31..bae88f7ab 100644 --- a/themes/jnrowe.zsh-theme +++ b/themes/jnrowe.zsh-theme @@ -1,7 +1,6 @@ autoload -U add-zsh-hook autoload -Uz vcs_info -zstyle ':vcs_info:*' disable-patterns "/usr/(ports|src)(|/*)" zstyle ':vcs_info:*' actionformats \ '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' zstyle ':vcs_info:*' formats '%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f ' From 76f2429e8ec30afacd3a913018c8c573962e214c Mon Sep 17 00:00:00 2001 From: Marcelo Eden Date: Tue, 14 Aug 2012 12:23:11 -0300 Subject: [PATCH 4/6] new 3den theme with RVM and GIT --- themes/3den.zsh-theme | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 themes/3den.zsh-theme diff --git a/themes/3den.zsh-theme b/themes/3den.zsh-theme new file mode 100644 index 000000000..1d2c7db7f --- /dev/null +++ b/themes/3den.zsh-theme @@ -0,0 +1,7 @@ +PROMPT=$'%{$fg[white]%}$(~/.rvm/bin/rvm-prompt) %{$fg_bold[cyan]%}%~%{$reset_color%}$(git_prompt_info) %{$fg[cyan]%}%D{[%I:%M:%S]}\ +%{$fg_bold[green]%}%n$%{$reset_color%} ' + +ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[white]%}(" +ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="*" +ZSH_THEME_GIT_PROMPT_CLEAN="" From b2c1af91d3e70ea442ae5353cf7f140d89491c73 Mon Sep 17 00:00:00 2001 From: John Hamelink Date: Sun, 19 Aug 2012 14:03:23 +0100 Subject: [PATCH 5/6] Added laravel plugin which gives aliases to artisan and bob, and provides autocompletion for artisan. --- plugins/laravel/_artisan | 40 ++++++++++++++++++++++++++++++ plugins/laravel/laravel.plugin.zsh | 3 +++ 2 files changed, 43 insertions(+) create mode 100644 plugins/laravel/_artisan create mode 100644 plugins/laravel/laravel.plugin.zsh diff --git a/plugins/laravel/_artisan b/plugins/laravel/_artisan new file mode 100644 index 000000000..8637514cf --- /dev/null +++ b/plugins/laravel/_artisan @@ -0,0 +1,40 @@ +#compdef artisan + +# Laravel autocompletion +# Author: John Hamelink +# +# This plugin does the following: +# - Adds aliases and autocompletion for artisan +# - Adds aliases and autocompletion for bob + +local curcontext="$curcontext" state line _opts _bundles ret=1 +_arguments -C \ + '1: :->cmds' \ + '*:: :->args' && ret=0 + +case $state in + cmds) + + _values "Artisan command" \ + 'session\:install[Create a session table]' \ + 'migrate[Manage Migrations]' \ + 'test[Run a test]' \ + 'route\:\:call[Call a route in the CLI]' \ + 'key\:\:generate[Generate a key]' + ret=0 + ;; + args) + case $line[1] in + migrate) + _values \ + 'install[Create the Laravel migration table' \ + 'make[Create a migration]' \ + 'rollback[Roll back to the last migration operation]' \ + 'reset[Roll back all migrations that have ever run]' + ret=0 + ;; + esac + ;; +esac + +return ret diff --git a/plugins/laravel/laravel.plugin.zsh b/plugins/laravel/laravel.plugin.zsh new file mode 100644 index 000000000..ed932ee89 --- /dev/null +++ b/plugins/laravel/laravel.plugin.zsh @@ -0,0 +1,3 @@ +#!zsh +alias artisan='php artisan' +alias bob='php artisan bob::build' From fbf82ae62fe03f69af0114011c0d6848a83d4fb3 Mon Sep 17 00:00:00 2001 From: everbird Date: Sat, 1 Sep 2012 23:11:47 +0800 Subject: [PATCH 6/6] add new plugin to autocomplete supervisor commands --- plugins/supervisor/_supervisorctl | 136 +++++++++++++++++++++++ plugins/supervisor/_supervisord | 32 ++++++ plugins/supervisor/supervisor.plugin.zsh | 1 + 3 files changed, 169 insertions(+) create mode 100644 plugins/supervisor/_supervisorctl create mode 100644 plugins/supervisor/_supervisord create mode 100644 plugins/supervisor/supervisor.plugin.zsh diff --git a/plugins/supervisor/_supervisorctl b/plugins/supervisor/_supervisorctl new file mode 100644 index 000000000..d159f20e0 --- /dev/null +++ b/plugins/supervisor/_supervisorctl @@ -0,0 +1,136 @@ +#compdef supervisorctl + +typeset -A opt_args +local context state line + +_supervisorctl() { + _arguments -s -S \ + {--configuration,-c}"[configuration file path (default /etc/supervisor.conf)]:FILENAME:_files" \ + {--help,-h}"[print usage message and exit]:" \ + {--interactive,-i}"[start an interactive shell after executing commands]" \ + {--serverurl,-s}"[URL on which supervisord server is listening (default "http://localhost:9001").]" \ + {--username,-u}"[username to use for authentication with server]:USERNAME:_users" \ + {--password,-p}"[password to use for authentication with server]:PASSWORD:" \ + {--history-file,-r}"[keep a readline history (if readline is available)]:FILENAME:_files" \ + "*::supervisorctl commands:_supervisorctl_command" +} + +(( $+functions[_supervisorctl_command] )) || +_supervisorctl_command() { + local cmd ret=1 + + (( $+supervisorctl_cmds )) || _supervisorctl_cmds=( + "add:Activates any updates in config for process/group" \ + "avail:Display all configured processes" \ + "clear:Clear process/multiple-process/all-process log files" \ + "exit:Exit the supervisor shell." \ + "fg:Connect to a process in foreground mode" \ + "maintail:tail of supervisor main log file" \ + "open:Connect to a remote supervisord process. (for UNIX domain socket, use unix:///socket/path)" \ + "pid:Get the PID of supervisord." \ + "quit:Exit the supervisor shell." \ + "reload:Restart the remote supervisord." \ + "remove:Removes process/group from active config" \ + "reread:Reload the daemon's configuration files" \ + "restart:Restart process or group." \ + "shutdown:Shut the remote supervisord down." \ + "start:Start process or groups." \ + "status:Get process status info." \ + "stop:Stop process or group." \ + "tail:tail of process stdout" \ + "update:Reload config and add/remove as necessary" \ + "version:Show the version of the remote supervisord process" \ + "help:Show help" \ + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'supervisorctl subcommand' _supervisorctl_cmds \ + || compadd "$@" - ${(s.:.)${(j.:.)_supervisorctl_syns}} + else + local curcontext="$curcontext" + + cmd="${${_supervisorctl_cmds[(r)$words[1]:*]%%:*}:-${(k)_supervisorctl_syns[(r)(*:|)$words[1](:*|)]}}" + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:supervisorctl-${cmd}:" + _call_function ret _supervisorctl_$cmd || _message 'no more arguments' + else + _message "unknown supervisorctl command: $words[1]" + fi + return ret + fi +} + +# get supervisor contoroll processes +(( $+functions[_get_supervisor_procs] )) || +_get_supervisor_procs() { + local cache_policy + zstyle -s ":completion:${curcontext}:" cache-policy cache_policy + if [[ -z "$cache_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _supervisor_procs_caching_policy + fi + + if ( [[ ${+_supervisor_procs} -eq 0 ]] || _cache_invalid supervisor_procs ) \ + && ! _retrieve_cache supervisor_procs; then + + _supervisor_procs=(${${(f)"$(supervisorctl status >/dev/null 2>&1 | awk -F' ' '{print $1}')"}}) + _store_cache supervisor_procs _supervisor_procs + fi + + local expl + _wanted supervisor_procs expl 'supervisor processes' compadd -a _supervisor_procs +} + +_supervisor_procs_caching_policy() { + local -a oldp + oldp=( "$1"(Nmw+1) ) + (( $#oldp )) +} + +(( $+functions[_supervisorctl_add] )) || +_supervisorctl_add() { + _arguments -s \ + "--help[use help system]" \ + "*::supervisorctl commands:_supervisorctl" +} + +(( $+functions[_supervisorctl_help] )) || +_supervisorctl_help() { + _arguments -s \ + "*:supervisorctl commands:_supervisorctl" +} + +(( $+functions[_supervisorctl_maintail] )) || +_supervisorctl_maintail() { + _arguments -s \ + '-f[Continuous tail of supervisor main log file (Ctrl-C to exit)]' +} + +(( $+functions[_supervisorctl_start] )) || +_supervisorctl_start() { + # TODO: add 'all' + _arguments -s \ + '*::supvervisor process:_get_supervisor_procs' +} + +(( $+functions[_supervisorctl_status] )) || +_supervisorctl_status() { + _arguments \ + '*::supvervisor process:_get_supervisor_procs' +} + +(( $+functions[_supervisorctl_stop] )) || +_supervisorctl_stop() { + # TODO: add 'all' + _arguments -s \ + '*::supvervisor process:_get_supervisor_procs' +} + +(( $+functions[_supervisorctl_tail] )) || +_supervisorctl_tail() { + # TODO: add 'stderr' + _arguments -s \ + '-f[Continuous tail of named process stdout Ctrl-C to exit.]' \ + '*::supvervisor process:_get_supervisor_procs' +} + +_supervisorctl "$@" diff --git a/plugins/supervisor/_supervisord b/plugins/supervisor/_supervisord new file mode 100644 index 000000000..34d27805d --- /dev/null +++ b/plugins/supervisor/_supervisord @@ -0,0 +1,32 @@ +#compdef supervisord + +typeset -A opt_args +local context state line + +_arguments \ + {--configuration,-c}"[configuration file]:FILENAME:_files" \ + {--nodaemon,-n}"[run in the foreground (same as 'nodaemon true' in config file)]" \ + {--help,-h}"[print this usage message and exit]:" \ + {--user,-u}"[run supervisord as this user]:USER:_users" \ + {--umask,-m}"[use this umask for daemon subprocess (default is 022)]" \ + {--directory,-d}"[directory to chdir to when daemonized]" \ + {--logfile,-l}"[use FILENAME as logfile path]:FILENAME:_files" \ + {--logfile_maxbytes,-y}"[use BYTES to limit the max size of logfile]" \ + {--logfile_backups,-z}"[number of backups to keep when max bytes reached]" \ + {--loglevel,-e}"[use LEVEL as log level (debug,info,warn,error,critical)]:level:->levels" \ + {--pidfile,-j}"[write a pid file for the daemon process to FILENAME]:FILENAME:_files" \ + {--identifier,-i}"[identifier used for this instance of supervisord]" \ + {--childlogdir,-q}"[the log directory for child process logs]:child log directory:_files -/" \ + {--nocleanup,-k}"[prevent the process from performing cleanup (removal of old automatic child log files) at startup.]" \ + {--minfds,-a}"[the minimum number of file descriptors for start success]" \ + {--strip_ansi,-t}"[strip ansi escape codes from process output]" \ + "--minprocs[the minimum number of processes available for start success]" \ + "--profile_options[run supervisord under profiler and output results based on OPTIONS, which is a comma-sep'd list of 'cumulative', 'calls', and/or 'callers', e.g. 'cumulative,callers')]" \ + "*::args:_gnu_generic" + +case $state in +levels) + levels=("debug" "info" "warn" "error" "critical") + _describe -t levels 'supervisord levels' levels && return 0 + ;; +esac diff --git a/plugins/supervisor/supervisor.plugin.zsh b/plugins/supervisor/supervisor.plugin.zsh new file mode 100644 index 000000000..cf1997c5b --- /dev/null +++ b/plugins/supervisor/supervisor.plugin.zsh @@ -0,0 +1 @@ +# DECLARION: This plugin was created by hhatto. What I did is just making a portal from https://bitbucket.org/hhatto/zshcompfunc4supervisor.