From 87ab8771dac655272895e5904fcf93217ea4a64b Mon Sep 17 00:00:00 2001 From: Sebastian Nowak Date: Sun, 15 Jul 2012 21:26:30 +0200 Subject: [PATCH 01/35] 'rails' command should not be run with bundle exec http://blog.wyeworks.com/2011/12/27/bundle-exec-rails-executes-bundler-setup-3-times http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/ --- plugins/bundler/bundler.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 1ca48089..39b76ecd 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -6,7 +6,7 @@ alias bu="bundle update" # The following is based on https://github.com/gma/bundler-exec -bundled_commands=(annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rails rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails) +bundled_commands=(annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails) ## Functions From 6a2e04fefbd794f050d45e7a717d009e39204431 Mon Sep 17 00:00:00 2001 From: clutton Date: Mon, 16 Jul 2012 02:59:30 +0300 Subject: [PATCH 02/35] =?UTF-8?q?modify=20themes/jnrowe.zsh-theme,=20add?= =?UTF-8?q?=20host=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 7c8a7082..0ade9cc6 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 1c23a52f5744ef419e83733d18a6a698ddd14d1e Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Fri, 20 Jul 2012 15:07:51 -0700 Subject: [PATCH 03/35] auto-upadate feature will now reset the epoch so that if a user doesn't say yes, it won't ask them again for a while. fixes #1240 --- tools/check_for_upgrade.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index bbd705a1..612901cb 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -32,9 +32,10 @@ then echo "[Oh My Zsh] Would you like to check for updates?" echo "Type Y to update oh-my-zsh: \c" read line - if [ "$line" = Y ] || [ "$line" = y ] - then + if [ "$line" = Y ] || [ "$line" = y ]; then _upgrade_zsh + else + _update_zsh_update fi fi fi From d5bfbf05d16634fa3c2834c7097edb1cf2487d96 Mon Sep 17 00:00:00 2001 From: clutton Date: Tue, 24 Jul 2012 05:36:18 +0300 Subject: [PATCH 04/35] 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 0ade9cc6..a1478be3 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 05/35] 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 a1478be3..bae88f7a 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 06/35] 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 00000000..1d2c7db7 --- /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 07/35] 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 00000000..8637514c --- /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 00000000..ed932ee8 --- /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 08/35] 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 00000000..d159f20e --- /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 00000000..34d27805 --- /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 00000000..cf1997c5 --- /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. From 061a4c006c83c9ddb2c8c693c2169d5be663763f Mon Sep 17 00:00:00 2001 From: Josh Parnham Date: Thu, 6 Sep 2012 19:59:18 +1000 Subject: [PATCH 09/35] Add new 'nanoc' plugin --- plugins/nanoc/_nanoc | 44 ++++++++++++++++++++++++++++++++++ plugins/nanoc/nanoc.plugin.zsh | 9 +++++++ 2 files changed, 53 insertions(+) create mode 100644 plugins/nanoc/_nanoc create mode 100644 plugins/nanoc/nanoc.plugin.zsh diff --git a/plugins/nanoc/_nanoc b/plugins/nanoc/_nanoc new file mode 100644 index 00000000..fde07c3f --- /dev/null +++ b/plugins/nanoc/_nanoc @@ -0,0 +1,44 @@ +#compdef nanoc +#autoload + +# nanoc zsh completion - based on the homebrew zsh completion +# requires the 'nanoc' gem to be installed + +local -a _1st_arguments +_1st_arguments=( + 'autocompile:start the autocompiler' + 'compile:compile items of this site' + 'create-item:create an item' + 'create-layout:create a layout' + 'create-site:create a site' + 'deploy:deploy the compiled site' + 'help:show help' + 'prune:remove files not managed by nanoc from the output directory' + 'show-data:show data in this site' + 'show-plugins:show all available plugins' + 'show-rules:describe the rules for each item' + 'update:update the data stored by the data source to a newer version' + 'validate-css:validate the site’s CSS' + 'validate-html:validate the site’s HTML' + 'validate-links:validate links in site' + 'view:start the web server that serves static files' + 'watch:start the watcher' +) + +local expl +local -a pkgs installed_pkgs + +_arguments \ + '(--color)--color[enable color]' \ + '(--debug)--debug[enable debugging]' \ + '(--help)--help[show the help message and quit]' \ + '(--no-color)--no-color[disable color]' \ + '(--verbose)--verbose[make nanoc output more detailed]' \ + '(--version)--version[show version information and quit]' \ + '(--warn)--warn[enable warnings]' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "nanoc subcommand" _1st_arguments + return +fi diff --git a/plugins/nanoc/nanoc.plugin.zsh b/plugins/nanoc/nanoc.plugin.zsh new file mode 100644 index 00000000..5a506461 --- /dev/null +++ b/plugins/nanoc/nanoc.plugin.zsh @@ -0,0 +1,9 @@ +alias n='nanoc' +alias na='nanoc autocompile' +alias nco='nanoc compile' +alias nci='nanoc create_item' +alias ncl='nanoc create_layout' +alias ncs='nanoc create_site' +alias nd='nanoc deploy' +alias nv='nanoc view' +alias nw='nanoc watch' From 8d60a0c80039048b836205475dfcf258bd776912 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Thu, 13 Sep 2012 11:38:58 +0200 Subject: [PATCH 10/35] updated cap plugin to use `cap -T` instead of `cap show_tasks` which didn't exist (sometimes?) --- plugins/cap/cap.plugin.zsh | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/plugins/cap/cap.plugin.zsh b/plugins/cap/cap.plugin.zsh index 8336182d..04479f46 100644 --- a/plugins/cap/cap.plugin.zsh +++ b/plugins/cap/cap.plugin.zsh @@ -1,8 +1,30 @@ -function _cap_does_task_list_need_generating () { - if [ ! -f .cap_tasks~ ]; then return 0; +stat -f%m . > /dev/null 2>&1 +if [ "$?" = 0 ]; then + stat_cmd=(stat -f%m) +else + stat_cmd=(stat -L --format=%y) +fi + +# Cache filename +_cap_show_undescribed_tasks=0 + +# Cache filename +_cap_task_cache_file='.cap_task_cache' + +_cap_get_task_list () { + if [ ${_cap_show_undescribed_tasks} -eq 0 ] + cap -T | grep '^cap' | cut -d " " -f 2 else - accurate=$(stat -f%m .cap_tasks~) - changed=$(stat -f%m config/deploy.rb) + cap -vT | grep '^cap' | cut -d " " -f 2 + fi +} + +_cap_does_task_list_need_generating () { + + if [ ! -f ${_cap_task_cache_file} ]; then return 0; + else + accurate=$($stat_cmd $_cap_task_cache_file) + changed=$($stat_cmd config/deploy.rb) return $(expr $accurate '>=' $changed) fi } @@ -10,12 +32,10 @@ function _cap_does_task_list_need_generating () { function _cap () { if [ -f config/deploy.rb ]; then if _cap_does_task_list_need_generating; then - echo "\nGenerating .cap_tasks~..." > /dev/stderr - cap show_tasks -q | cut -d " " -f 1 | sed -e '/^ *$/D' -e '1,2D' -> .cap_tasks~ + _cap_get_task_list > ${_cap_task_cache_file} fi - compadd `cat .cap_tasks~` + compadd `cat ${_cap_task_cache_file}` fi } -compctl -K _cap cap +compdef _cap cap From 9a4fac184ea1aa7a2e86e50111548a0a98652aaf Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Thu, 13 Sep 2012 12:20:44 +0200 Subject: [PATCH 11/35] fixed incorrect if/else --- plugins/cap/cap.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cap/cap.plugin.zsh b/plugins/cap/cap.plugin.zsh index 04479f46..d22d1040 100644 --- a/plugins/cap/cap.plugin.zsh +++ b/plugins/cap/cap.plugin.zsh @@ -12,7 +12,7 @@ _cap_show_undescribed_tasks=0 _cap_task_cache_file='.cap_task_cache' _cap_get_task_list () { - if [ ${_cap_show_undescribed_tasks} -eq 0 ] + if [ ${_cap_show_undescribed_tasks} -eq 0 ]; then cap -T | grep '^cap' | cut -d " " -f 2 else cap -vT | grep '^cap' | cut -d " " -f 2 From b11e28914139fb585c0a4de4ddb6a55f19a5493d Mon Sep 17 00:00:00 2001 From: Isaac Wolkerstorfer Date: Thu, 13 Sep 2012 14:02:09 +0200 Subject: [PATCH 12/35] Add agnoster.zsh-theme --- themes/agnoster.zsh-theme | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 themes/agnoster.zsh-theme diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme new file mode 100644 index 00000000..15848979 --- /dev/null +++ b/themes/agnoster.zsh-theme @@ -0,0 +1,28 @@ +# Theme by [agnoster](https://github.com/agnoster) +# See https://gist.github.com/3712874 + +ZSH_THEME_GIT_PROMPT_DIRTY='±' + +function _git_prompt_info() { + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + echo "${ref/refs\/heads\//⭠ }$(parse_git_dirty)" +} + +function _git_info() { + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + local BG_COLOR=green + if [[ -n $(parse_git_dirty) ]]; then + BG_COLOR=yellow + fi + echo "%{%K{$BG_COLOR}%}⮀%{%F{black}%} $(_git_prompt_info) %{%F{$BG_COLOR}%K{blue}%}⮀" + else + echo "%{%K{blue}%}⮀" + fi +} + +PROMPT_HOST='%{%b%F{gray}%K{black}%} %(?.%{%F{green}%}✔.%{%F{red}%}✘)%{%F{gray}%} %m %{%F{black}%}' +PROMPT_DIR='%{%F{white}%} %1~ ' +PROMPT_SU='%(!.%{%k%F{blue}%K{black}%}⮀%{%F{yellow}%} ⚡ %{%k%F{black}%}.%{%k%F{blue}%})⮀%{%f%k%b%}' + +PROMPT='%{%f%b%k%} +$PROMPT_HOST$(_git_info)$PROMPT_DIR$PROMPT_SU ' From bf4157514f8880ac04ba328f7f1b74c34f1b39d7 Mon Sep 17 00:00:00 2001 From: Isaac Wolkerstorfer Date: Mon, 17 Sep 2012 11:44:25 -0500 Subject: [PATCH 13/35] Refactored theme --- themes/agnoster.zsh-theme | 96 +++++++++++++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 19 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 15848979..9cfcff3d 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -1,28 +1,86 @@ -# Theme by [agnoster](https://github.com/agnoster) -# See https://gist.github.com/3712874 +### Segment drawing +# A few utility functions to make it easy and re-usable to draw segmented prompts -ZSH_THEME_GIT_PROMPT_DIRTY='±' - -function _git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" - echo "${ref/refs\/heads\//⭠ }$(parse_git_dirty)" +CURRENT_BG='' +SEGMENT_SEPARATOR='⮀' +function segment_start() { + local bg=$1 + local fg=$2 + if [[ -n $CURRENT_BG && $bg != $CURRENT_BG ]]; then + echo -n " %{%K{$bg}%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + else + echo -n "%{%K{$bg}%}" + fi + [[ -n $fg ]] && fg="%F{$fg}" || fg="%f" + echo -n "%{$fg%} " + CURRENT_BG=$bg } -function _git_info() { - if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then - local BG_COLOR=green - if [[ -n $(parse_git_dirty) ]]; then - BG_COLOR=yellow - fi - echo "%{%K{$BG_COLOR}%}⮀%{%F{black}%} $(_git_prompt_info) %{%F{$BG_COLOR}%K{blue}%}⮀" +function segment_stop() { + if [[ -n $CURRENT_BG ]]; then + echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" else - echo "%{%K{blue}%}⮀" + echo -n "%{%k%}" + fi + echo -n "%{%f%}" + CURRENT_BG='' +} + +### Prompt components +# Each component will draw itself, and hide itself if no information needs to be shown + +function prompt_context() { + local user=`whoami` + + if [[ ("$user" != "$DEFAULT_USER") || (-n "$SSH_CLIENT") ]]; then + segment_start black + #echo -n "%{%F{yellow}%}$user%{%F{gray}%}@%{%F{green}%}%m%{%f%}" + echo -n "%(!.%{%F{yellow}%}.)$user@%m" fi } -PROMPT_HOST='%{%b%F{gray}%K{black}%} %(?.%{%F{green}%}✔.%{%F{red}%}✘)%{%F{gray}%} %m %{%F{black}%}' -PROMPT_DIR='%{%F{white}%} %1~ ' -PROMPT_SU='%(!.%{%k%F{blue}%K{black}%}⮀%{%F{yellow}%} ⚡ %{%k%F{black}%}.%{%k%F{blue}%})⮀%{%f%k%b%}' +function prompt_git() { + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + ZSH_THEME_GIT_PROMPT_DIRTY='±' + local dirty=$(parse_git_dirty) + local ref + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" + if [[ -n $dirty ]]; then + segment_start yellow black + else + segment_start green black + fi + echo -n "${ref/refs\/heads\//⭠ }$dirty" + fi +} + +function prompt_dir() { + segment_start blue white + echo -n '%~' +} + +function prompt_status() { + local symbols + symbols=() + [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" + [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" + jobs=$(jobs -l | wc -l) + [[ $jobs -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + if [[ -n "$symbols" ]]; then + segment_start black white + echo -n "${symbols}" + fi +} + +## Main prompt +function build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + segment_stop +} PROMPT='%{%f%b%k%} -$PROMPT_HOST$(_git_info)$PROMPT_DIR$PROMPT_SU ' +$(build_prompt) ' From 8510ac002f1dec92f6e9e62809f3dc5493d4b842 Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Mon, 17 Sep 2012 19:05:42 -0700 Subject: [PATCH 14/35] Bundle exec puma also http://puma.io --- plugins/bundler/bundler.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 39b76ecd..2305c497 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -6,7 +6,7 @@ alias bu="bundle update" # The following is based on https://github.com/gma/bundler-exec -bundled_commands=(annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails) +bundled_commands=(annotate cap capify cucumber foreman guard middleman nanoc rackup rainbows rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails puma) ## Functions From b609aa0e6c981f2039d777687cb01a84587f6edc Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Thu, 20 Sep 2012 08:03:09 -0400 Subject: [PATCH 15/35] Fix to restore bindings after switching to vi-mode the vi-mode plugin destroys any bindings made before it is sourced due to the 'bindkey -v' call to switch to using vi-mode. This patch saves the bindings before invoking 'bindkey -v' then rebinds them afterwards, this fixes a number of outstanding issues due to people using vi-mode and having things in oh-my-zsh break due to the bindings being destroyed --- plugins/vi-mode/vi-mode.plugin.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index c47ab721..d29eb1dd 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -5,7 +5,12 @@ function zle-line-init zle-keymap-select { zle -N zle-line-init zle -N zle-keymap-select +#changing mode clobbers the keybinds, so store the keybinds before and execute +#them after +binds=`bindkey -L` bindkey -v +for bind in ${(@f)binds}; do eval $bind; done +unset binds # if mode indicator wasn't setup by theme, define default if [[ "$MODE_INDICATOR" == "" ]]; then From baa187e4b903f39422a84b580e6e617ec3738e09 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Thu, 20 Sep 2012 08:23:58 -0400 Subject: [PATCH 16/35] Per directory history plugin This is a implementation of per directory history for zsh, some implementations of which exist in bash[1,2]. It also implements a per-directory-history-toggle-history function to change from using the directory history to using the global history. In both cases the history is always saved to both the global history and the directory history, so the toggle state will not effect the saved histories. Being able to switch between global and directory histories on the fly is a novel feature as far as I am aware. [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html [2]: http://dieter.plaetinck.be/per_directory_bash --- .../per-directory-history.plugin.zsh | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 plugins/per-directory-history/per-directory-history.plugin.zsh diff --git a/plugins/per-directory-history/per-directory-history.plugin.zsh b/plugins/per-directory-history/per-directory-history.plugin.zsh new file mode 100644 index 00000000..ce36db6a --- /dev/null +++ b/plugins/per-directory-history/per-directory-history.plugin.zsh @@ -0,0 +1,149 @@ +#!/usr/bin/env zsh +# +# This is a implementation of per directory history for zsh, some +# implementations of which exist in bash[1,2]. It also implements +# a per-directory-history-toggle-history function to change from using the +# directory history to using the global history. In both cases the history is +# always saved to both the global history and the directory history, so the +# toggle state will not effect the saved histories. Being able to switch +# between global and directory histories on the fly is a novel feature as far +# as I am aware. +# +#------------------------------------------------------------------------------- +# Configuration +#------------------------------------------------------------------------------- +# +# HISTORY_BASE a global variable that defines the base directory in which the +# directory histories are stored +# +#------------------------------------------------------------------------------- +# History +#------------------------------------------------------------------------------- +# +# The idea/inspiration for a per directory history is from Stewart MacArthur[1] +# and Dieter[2], the implementation idea is from Bart Schaefer on the the zsh +# mailing list[3]. The implementation is by Jim Hester in September 2012. +# +# [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html +# [2]: http://dieter.plaetinck.be/per_directory_bash +# [3]: http://www.zsh.org/mla/users/1997/msg00226.html +# +################################################################################ +# +# Copyright (c) 2012 Jim Hester +# +# This software is provided 'as-is', without any express or implied warranty. +# In no event will the authors be held liable for any damages arising from the +# use of this software. +# +# Permission is granted to anyone to use this software for any purpose, +# including commercial applications, and to alter it and redistribute it +# freely, subject to the following restrictions: +# +# 1. The origin of this software must not be misrepresented; you must not claim +# that you wrote the original software. If you use this software in a product, +# an acknowledgment in the product documentation would be appreciated but is +# not required. +# +# 2. Altered source versions must be plainly marked as such, and must not be +# misrepresented as being the original software. +# +# 3. This notice may not be removed or altered from any source distribution.. +# +################################################################################ + +#------------------------------------------------------------------------------- +# configuration, the base under which the directory histories are stored +#------------------------------------------------------------------------------- + +[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history" + +#------------------------------------------------------------------------------- +# toggle global/directory history used for searching - ctrl-G by default +#------------------------------------------------------------------------------- + +function per-directory-history-toggle-history() { + if [[ $_per_directory_history_is_global == true ]]; then + _per-directory-history-set-directory-history + echo "using local history\n" + else + _per-directory-history-set-global-history + echo "using global history\n" + fi + zle reset-prompt +} + +autoload per-directory-history-toggle-history +zle -N per-directory-history-toggle-history +bindkey '^G' per-directory-history-toggle-history + +#------------------------------------------------------------------------------- +# implementation details +#------------------------------------------------------------------------------- + +_per_directory_history_global=$HISTFILE +_per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" + +function _per-directory-history-change-directory() { + _per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" + mkdir -p ${_per_directory_history_directory:h} + if [[ $_per_directory_history_is_global == false ]]; then + #save to the global history + fc -AI $_per_directory_history_global + #save history to previous file + local prev="$HISTORY_BASE${OLDPWD:A}/history" + mkdir -p ${prev:h} + fc -AI $prev + + #discard previous directory's history + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + + #read history in new file + if [[ -e $_per_directory_history_directory ]]; then + fc -R $_per_directory_history_directory + fi + fi +} + +function _per-directory-history-addhistory() { + print -sr -- ${1%%$'\n'} + fc -p $_per_directory_history_directory +} + + +function _per-directory-history-set-directory-history() { + if [[ $_per_directory_history_is_global == true ]]; then + fc -AI $_per_directory_history_global + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + if [[ -e "$_per_directory_history_directory" ]]; then + fc -R "$_per_directory_history_directory" + fi + fi + _per_directory_history_is_global=false +} +function _per-directory-history-set-global-history() { + if [[ $_per_directory_history_is_global == false ]]; then + fc -AI $_per_directory_history_directory + local original_histsize=$HISTSIZE + HISTSIZE=0 + HISTSIZE=$original_histsize + if [[ -e "$_per_directory_history_global" ]]; then + fc -R "$_per_directory_history_global" + fi + fi + _per_directory_history_is_global=true +} + + +#add functions to the exec list for chpwd and zshaddhistory +chpwd_functions=(${chpwd_functions[@]} "_per-directory-history-change-directory") +zshaddhistory_functions=(${zshaddhistory_functions[@]} "_per-directory-history-addhistory") + +#start in directory mode +mkdir -p ${_per_directory_history_directory:h} +_per_directory_history_is_global=true +_per-directory-history-set-directory-history From aeadd7371b244468aadf81a48e6009a4aa612f23 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Thu, 20 Sep 2012 08:29:05 -0400 Subject: [PATCH 17/35] Colemak plugin a plugin for useing the colemak[1] keyboard layout and vi-mode in zsh, rotates some keys around in vi command mode so that the physical hjkl keys are still used for movement, all the rotated keys are either in colemak's location or qwerty's location, so it is easy to pick up [1] www.colemak.com --- plugins/colemak/colemak-less | 6 ++++++ plugins/colemak/colemak.plugin.zsh | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 plugins/colemak/colemak-less create mode 100644 plugins/colemak/colemak.plugin.zsh diff --git a/plugins/colemak/colemak-less b/plugins/colemak/colemak-less new file mode 100644 index 00000000..e4ca4fac --- /dev/null +++ b/plugins/colemak/colemak-less @@ -0,0 +1,6 @@ +n forw-line +e back-line +k repeat-search +\ek repeat-search-all +K reverse-search +\eK reverse-search-all diff --git a/plugins/colemak/colemak.plugin.zsh b/plugins/colemak/colemak.plugin.zsh new file mode 100644 index 00000000..34d42c28 --- /dev/null +++ b/plugins/colemak/colemak.plugin.zsh @@ -0,0 +1,22 @@ +# ctrl-j newline +bindkey '^n' accept-line +bindkey -a '^n' accept-line + +# another rotation to match qwerty +bindkey -a 'n' down-line-or-history +bindkey -a 'e' up-line-or-history +bindkey -a 'i' vi-forward-char + +# make qwerty +bindkey -a 'k' vi-repeat-search +bindkey -a 'K' vi-rev-repeat-search +bindkey -a 'u' vi-insert +bindkey -a 'U' vi-insert-bol +bindkey -a 'l' vi-undo-change +bindkey -a 'N' vi-join + +# spare +bindkey -a 'j' vi-forward-word-end +bindkey -a 'J' vi-forward-blank-word-end + +lesskey $ZSH_CUSTOM/plugins/colemak/colemak-less From 7284e6b397712dfff16a740ea12d1015b26f203d Mon Sep 17 00:00:00 2001 From: Aviad Reich Date: Fri, 21 Sep 2012 08:08:53 +0300 Subject: [PATCH 18/35] added autojump plugin support for mac os x + port --- plugins/autojump/autojump.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 6f0edb06..d367863b 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -3,6 +3,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed . /usr/share/autojump/autojump.zsh elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation . /etc/profile.d/autojump.zsh + elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports + . /opt/local/etc/profile.d/autojump.zsh elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump ]; then # mac os x with brew . `brew --prefix`/etc/autojump fi From cc831508d7c2e839e1c4effe31ac2d92f2741f94 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Fri, 21 Sep 2012 10:19:39 -0400 Subject: [PATCH 19/35] Use HISTFILE evironment variable directly rather than copying it Use the HISTFILE environment variable in place of copying it to _per_directory_history_global so that users can change the environment variable after sourcing per-directory-history and have the global variable set correctly --- .../per-directory-history.plugin.zsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/per-directory-history/per-directory-history.plugin.zsh b/plugins/per-directory-history/per-directory-history.plugin.zsh index ce36db6a..22383b8b 100644 --- a/plugins/per-directory-history/per-directory-history.plugin.zsh +++ b/plugins/per-directory-history/per-directory-history.plugin.zsh @@ -81,7 +81,6 @@ bindkey '^G' per-directory-history-toggle-history # implementation details #------------------------------------------------------------------------------- -_per_directory_history_global=$HISTFILE _per_directory_history_directory="$HISTORY_BASE${PWD:A}/history" function _per-directory-history-change-directory() { @@ -89,7 +88,7 @@ function _per-directory-history-change-directory() { mkdir -p ${_per_directory_history_directory:h} if [[ $_per_directory_history_is_global == false ]]; then #save to the global history - fc -AI $_per_directory_history_global + fc -AI $HISTFILE #save history to previous file local prev="$HISTORY_BASE${OLDPWD:A}/history" mkdir -p ${prev:h} @@ -115,7 +114,7 @@ function _per-directory-history-addhistory() { function _per-directory-history-set-directory-history() { if [[ $_per_directory_history_is_global == true ]]; then - fc -AI $_per_directory_history_global + fc -AI $HISTFILE local original_histsize=$HISTSIZE HISTSIZE=0 HISTSIZE=$original_histsize @@ -131,8 +130,8 @@ function _per-directory-history-set-global-history() { local original_histsize=$HISTSIZE HISTSIZE=0 HISTSIZE=$original_histsize - if [[ -e "$_per_directory_history_global" ]]; then - fc -R "$_per_directory_history_global" + if [[ -e "$HISTFILE" ]]; then + fc -R "$HISTFILE" fi fi _per_directory_history_is_global=true From 6e85ff5b44e81f5b9d743b6ba1df7ed7b62dc2df Mon Sep 17 00:00:00 2001 From: Isaac Wolkerstorfer Date: Tue, 25 Sep 2012 18:35:08 -0500 Subject: [PATCH 20/35] Updated documentation for agnoster theme --- themes/agnoster.zsh-theme | 99 +++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 35 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 9cfcff3d..71bc25fc 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -1,22 +1,51 @@ +# vim:ft=zsh ts=2 sw=2 sts=2 +# +# agnoster's Theme +# A Powerline-inspired theme for ZSH +# +# # README +# +# In order for this theme to render correctly, you will need a +# [Powerline-patched font](https://gist.github.com/1595572). +# +# In addition, I recommend the +# [Solarized theme](https://github.com/altercation/solarized/) and, if you're +# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app - +# it has significantly better color fidelity. +# +# # Goals +# +# The aim of this theme is to only show you *relevant* information. Like most +# prompts, it will only show git information when in a git working directory. +# However, it goes a step further: everything from the current user and +# hostname to whether the last call exited with an error to whether background +# jobs are running in this shell will all be displayed automatically when +# appropriate. + ### Segment drawing # A few utility functions to make it easy and re-usable to draw segmented prompts -CURRENT_BG='' +CURRENT_BG='NONE' SEGMENT_SEPARATOR='⮀' -function segment_start() { - local bg=$1 - local fg=$2 - if [[ -n $CURRENT_BG && $bg != $CURRENT_BG ]]; then - echo -n " %{%K{$bg}%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" + +# Begin a segment +# Takes two arguments, background and foreground. Both can be omitted, +# rendering default background/foreground. +prompt_segment() { + local bg fg + [[ -n $1 ]] && bg="%K{$1}" || bg="%k" + [[ -n $2 ]] && fg="%F{$2}" || fg="%f" + if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then + echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " else - echo -n "%{%K{$bg}%}" + echo -n "%{$bg%}%{$fg%} " fi - [[ -n $fg ]] && fg="%F{$fg}" || fg="%f" - echo -n "%{$fg%} " - CURRENT_BG=$bg + CURRENT_BG=$1 + [[ -n $3 ]] && echo -n $3 } -function segment_stop() { +# End the prompt, closing any open segments +prompt_end() { if [[ -n $CURRENT_BG ]]; then echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" else @@ -29,58 +58,58 @@ function segment_stop() { ### Prompt components # Each component will draw itself, and hide itself if no information needs to be shown -function prompt_context() { +# Context: user@hostname (who am I and where am I) +prompt_context() { local user=`whoami` - if [[ ("$user" != "$DEFAULT_USER") || (-n "$SSH_CLIENT") ]]; then - segment_start black - #echo -n "%{%F{yellow}%}$user%{%F{gray}%}@%{%F{green}%}%m%{%f%}" - echo -n "%(!.%{%F{yellow}%}.)$user@%m" + if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then + prompt_segment black default "%(!.%{%F{yellow}%}.)$user@%m" fi } -function prompt_git() { +# Git: branch/detached head, dirty status +prompt_git() { + local ref dirty if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then ZSH_THEME_GIT_PROMPT_DIRTY='±' - local dirty=$(parse_git_dirty) - local ref + dirty=$(parse_git_dirty) ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)" if [[ -n $dirty ]]; then - segment_start yellow black + prompt_segment yellow black else - segment_start green black + prompt_segment green black fi echo -n "${ref/refs\/heads\//⭠ }$dirty" fi } -function prompt_dir() { - segment_start blue white - echo -n '%~' +# Dir: current working directory +prompt_dir() { + prompt_segment blue black '%~' } -function prompt_status() { +# Status: +# - was there an error +# - am I root +# - are there background jobs? +prompt_status() { local symbols symbols=() [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" - jobs=$(jobs -l | wc -l) - [[ $jobs -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" - if [[ -n "$symbols" ]]; then - segment_start black white - echo -n "${symbols}" - fi + [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" + + [[ -n "$symbols" ]] && prompt_segment black default "$symbols" } ## Main prompt -function build_prompt() { +build_prompt() { RETVAL=$? prompt_status prompt_context prompt_dir prompt_git - segment_stop + prompt_end } -PROMPT='%{%f%b%k%} -$(build_prompt) ' +PROMPT='%{%f%b%k%}$(build_prompt) ' From b207792f30f523e2fc82a70e75893bf1124bf7a8 Mon Sep 17 00:00:00 2001 From: Isaac Wolkerstorfer Date: Tue, 25 Sep 2012 19:06:13 -0500 Subject: [PATCH 21/35] Add link to gist --- themes/agnoster.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 71bc25fc..c3107c06 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -1,6 +1,6 @@ # vim:ft=zsh ts=2 sw=2 sts=2 # -# agnoster's Theme +# agnoster's Theme - https://gist.github.com/3712874 # A Powerline-inspired theme for ZSH # # # README From 3d1b788d8ad3b4c407d3c752de15318cf57cf03e Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Tue, 8 Nov 2011 12:24:14 -0800 Subject: [PATCH 22/35] Fixing the rvm_prompt_info command, now it will not show empty parens if no rvm is currently being used --- lib/rvm.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rvm.zsh b/lib/rvm.zsh index 597be1b3..dbfaf879 100644 --- a/lib/rvm.zsh +++ b/lib/rvm.zsh @@ -1,6 +1,10 @@ # get the name of the branch we are on function rvm_prompt_info() { ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return + if [ -z $ruby_version ] + then + return + fi echo "($ruby_version)" } From a7fb6680789c0a45c23539f9cce623a920ae143e Mon Sep 17 00:00:00 2001 From: Trae Robrock Date: Wed, 26 Sep 2012 13:57:38 -0700 Subject: [PATCH 23/35] Make rvm prompt function a bit cleaner --- lib/rvm.zsh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/rvm.zsh b/lib/rvm.zsh index dbfaf879..cb870a9b 100644 --- a/lib/rvm.zsh +++ b/lib/rvm.zsh @@ -1,11 +1,5 @@ # get the name of the branch we are on function rvm_prompt_info() { ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return - if [ -z $ruby_version ] - then - return - fi - echo "($ruby_version)" + [[ ! -z $ruby_version ]] && echo "($ruby_version)" } - - From c7c647d8039987b802509519ffa631818cd1d194 Mon Sep 17 00:00:00 2001 From: Dominik Bamberger Date: Thu, 27 Sep 2012 11:51:16 +0200 Subject: [PATCH 24/35] Add zeus plugin Includes aliases for zeus (https://github.com/burke/zeus) Also there is a README.md that list all aliases, ready to copy into the wiki. --- plugins/zeus/README.md | 41 +++++++++++++++++++++++++ plugins/zeus/zeus.plugin.zsh | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 plugins/zeus/README.md create mode 100644 plugins/zeus/zeus.plugin.zsh diff --git a/plugins/zeus/README.md b/plugins/zeus/README.md new file mode 100644 index 00000000..2cb85cec --- /dev/null +++ b/plugins/zeus/README.md @@ -0,0 +1,41 @@ +## zeus +**Maintainer:** [b4mboo](https://github.com/b4mboo) + +* `zi` aliases `zeus init` +* `zinit` aliases `zeus init` + +* `zs` aliases `zeus start` +* `ztart` aliases `zeus start` + +* `zc` aliases `zeus console` +* `zonsole` aliases `zeus console` + +* `zsr` aliases `zeus server` +* `zerver` aliases `zeus server` + +* `zr` aliases `zeus rake` +* `zake` aliases `zeus rake` + +* `zg` aliases `zeus generate` +* `zenerate` aliases `zeus generate` + +* `zrn` aliases `zeus runner` +* `zunner` aliases `zeus runner` + +* `zcu` aliases `zeus cucumber` +* `zucumber` aliases `zeus cucumber` + +* `zt` aliases `zeus test` +* `zest` aliases `zeus test` + +* `zu` aliases `zeus test/units/*` +* `zunits` aliases `zeus test/units/*` + +* `zf` aliases `zeus test/functional/*` +* `zunctional` aliases `zeus test/functional/*` + +* `za` aliases `zeus test test/units/*; zeus test test/functional/; zeus cucumber` +* `zall` aliases `zeus test test/units/*; zeus test test/functional/; zeus cucumber` + +* `zsw` aliases `rm .zeus.sock` +* `zweep` aliases `rm .zeus.sock` diff --git a/plugins/zeus/zeus.plugin.zsh b/plugins/zeus/zeus.plugin.zsh new file mode 100644 index 00000000..48392f54 --- /dev/null +++ b/plugins/zeus/zeus.plugin.zsh @@ -0,0 +1,58 @@ +# Some aliases for zeus. (See: https://github.com/burke/zeus) +# Zeus preloads your Rails environment and forks that process whenever +# needed. This effectively speeds up Rails' boot process to under 1 sec. + +# Always use bundler. +# Rails depends on bundler, so we can be pretty sure, that there are no +# problems with this command. For all the other aliases I provided an +# alternative, in case people have conflicts with other plugins (e.g. suse). +alias zeus='bundle exec zeus' + +# Init +alias zi='zeus init' +alias zinit='zeus init' + +# Start +alias zs='zeus start' +alias ztart='zeus start' + +# Console +alias zc='zeus console' +alias zonsole='zeus console' + +# Server +alias zsr='zeus server' +alias zerver='zeus server' + +# Rake +alias zr='zeus rake' +alias zake='zeus rake' + +# Generate +alias zg='zeus generate' +alias zenerate='zeus generate' + +# Runner +alias zrn='zeus runner' +alias zunner='zeus runner' + +# Cucumber +alias zcu='zeus cucumber' +alias zucumber='zeus cucumber' + +# Test +alias zt='zeus test' +alias zest='zeus test' + +alias zu='zeus test/units/*' +alias zunits='zeus test/units/*' + +alias zf='zeus test/functional/*' +alias zunctional='zeus test/functional/*' + +alias za='zeus test test/units/*; zeus test test/functional/; zeus cucumber' +alias zall='zeus test test/units/*; zeus test test/functional/; zeus cucumber' + +# Clean up crashed zeus instances. +alias zsw='rm .zeus.sock' +alias zweep='rm .zeus.sock' From 2bbe6aba8f90dabdb3f7e2caaf12b6a3ecaf5f1f Mon Sep 17 00:00:00 2001 From: Paul Redmond Date: Fri, 28 Sep 2012 22:41:30 -0700 Subject: [PATCH 25/35] Jira ticket shortcut to browse existing issues or create a new issue. --- plugins/jira/jira.plugin.zsh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/jira/jira.plugin.zsh diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh new file mode 100644 index 00000000..c8b17d71 --- /dev/null +++ b/plugins/jira/jira.plugin.zsh @@ -0,0 +1,22 @@ +# To use: add a .jira-url file containing your +# Jira project's base url in the root of your project. +# Example: https://name.jira.com +# Usage: jira # opens a new issue +# jira ABC-123 # Opens an existing issue +open_jira_issue () { + if [ ! -f .jira-url ]; then + echo "There is no .jira-url file in the current directory or your home folder..." + return 0; + else + jira_url=$(cat .jira-url); + if [ -z "$1" ]; then + echo "Opening new issue"; + `open $jira_url/secure/CreateIssue!default.jspa`; + else + echo "Opening issue #$1"; + `open $jira_url/issues/$1`; + fi + fi +} + +alias jira='open_jira_issue' From 2d660161027a5c6a6876520dd264df7fdab7c044 Mon Sep 17 00:00:00 2001 From: Paul Redmond Date: Fri, 28 Sep 2012 22:48:18 -0700 Subject: [PATCH 26/35] Clean up doc --- plugins/jira/jira.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index c8b17d71..d19296cb 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,6 +1,6 @@ -# To use: add a .jira-url file containing your -# Jira project's base url in the root of your project. -# Example: https://name.jira.com +# To use: add a .jira-url file in the base of your project +# Setup: cd to/my/project + echo "https://name.jira.com" >> .jira-url # Usage: jira # opens a new issue # jira ABC-123 # Opens an existing issue open_jira_issue () { From b559f2f22127b3bf7f30dd5221fd8cb5ff3808fc Mon Sep 17 00:00:00 2001 From: Paul Redmond Date: Fri, 28 Sep 2012 23:00:15 -0700 Subject: [PATCH 27/35] Correct error message. --- plugins/jira/jira.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index d19296cb..f63743c9 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -5,7 +5,7 @@ # jira ABC-123 # Opens an existing issue open_jira_issue () { if [ ! -f .jira-url ]; then - echo "There is no .jira-url file in the current directory or your home folder..." + echo "There is no .jira-url file in the current directory..." return 0; else jira_url=$(cat .jira-url); From b7383b097e2b1dc6aaec2c906e7d2031f9446fba Mon Sep 17 00:00:00 2001 From: Dominik Bamberger Date: Mon, 1 Oct 2012 16:24:50 +0200 Subject: [PATCH 28/35] look for test/unit instead of test/units. #typo --- plugins/zeus/zeus.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/zeus/zeus.plugin.zsh b/plugins/zeus/zeus.plugin.zsh index 48392f54..65fd88d9 100644 --- a/plugins/zeus/zeus.plugin.zsh +++ b/plugins/zeus/zeus.plugin.zsh @@ -44,14 +44,14 @@ alias zucumber='zeus cucumber' alias zt='zeus test' alias zest='zeus test' -alias zu='zeus test/units/*' -alias zunits='zeus test/units/*' +alias zu='zeus test/unit/*' +alias zunits='zeus test/unit/*' alias zf='zeus test/functional/*' alias zunctional='zeus test/functional/*' -alias za='zeus test test/units/*; zeus test test/functional/; zeus cucumber' -alias zall='zeus test test/units/*; zeus test test/functional/; zeus cucumber' +alias za='zeus test test/unit/*; zeus test test/functional/; zeus cucumber' +alias zall='zeus test test/unit/*; zeus test test/functional/; zeus cucumber' # Clean up crashed zeus instances. alias zsw='rm .zeus.sock' From 9acfaee2567bcbe8dcd3dc73a8d40c0983766fb6 Mon Sep 17 00:00:00 2001 From: Paul Redmond Date: Mon, 1 Oct 2012 09:27:52 -0700 Subject: [PATCH 29/35] Missing comment line --- plugins/jira/jira.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index f63743c9..636e4619 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -1,6 +1,6 @@ # To use: add a .jira-url file in the base of your project # Setup: cd to/my/project - echo "https://name.jira.com" >> .jira-url +# echo "https://name.jira.com" >> .jira-url # Usage: jira # opens a new issue # jira ABC-123 # Opens an existing issue open_jira_issue () { From b932312ab78b7f422f501d03aaa577440bcd3a0c Mon Sep 17 00:00:00 2001 From: Dominik Bamberger Date: Tue, 2 Oct 2012 18:10:40 +0200 Subject: [PATCH 30/35] fix test aliases --- plugins/zeus/zeus.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/zeus/zeus.plugin.zsh b/plugins/zeus/zeus.plugin.zsh index 65fd88d9..2fc7e1eb 100644 --- a/plugins/zeus/zeus.plugin.zsh +++ b/plugins/zeus/zeus.plugin.zsh @@ -44,11 +44,11 @@ alias zucumber='zeus cucumber' alias zt='zeus test' alias zest='zeus test' -alias zu='zeus test/unit/*' -alias zunits='zeus test/unit/*' +alias zu='zeus test test/unit/*' +alias zunits='zeus test test/unit/*' -alias zf='zeus test/functional/*' -alias zunctional='zeus test/functional/*' +alias zf='zeus test test/functional/*' +alias zunctional='zeus test test/functional/*' alias za='zeus test test/unit/*; zeus test test/functional/; zeus cucumber' alias zall='zeus test test/unit/*; zeus test test/functional/; zeus cucumber' From e3de97ca89368bb433034431778a29f7f09db6c2 Mon Sep 17 00:00:00 2001 From: Daniel Gomes Date: Fri, 5 Oct 2012 21:12:40 +0100 Subject: [PATCH 31/35] added two aliases to Symfony2 Plugin --- plugins/symfony2/symfony2.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh index 64426684..22340129 100644 --- a/plugins/symfony2/symfony2.plugin.zsh +++ b/plugins/symfony2/symfony2.plugin.zsh @@ -10,4 +10,8 @@ _symfony2 () { fi } -compdef _symfony2 app/console \ No newline at end of file +compdef _symfony2 app/console + +#Alias +alias sf2='php app/console' +alias sf2clear='php app/console cache:clear' \ No newline at end of file From 6630919bce0ec9eb5ad33c26a32cd5f06529d570 Mon Sep 17 00:00:00 2001 From: Daniel Gomes Date: Fri, 5 Oct 2012 21:13:10 +0100 Subject: [PATCH 32/35] added Composer completition and aliases --- plugins/composer/composer.plugin.zsh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plugins/composer/composer.plugin.zsh diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh new file mode 100644 index 00000000..a054ae2c --- /dev/null +++ b/plugins/composer/composer.plugin.zsh @@ -0,0 +1,28 @@ +# ------------------------------------------------------------------------------ +# FILE: composer.plugin.zsh +# DESCRIPTION: oh-my-zsh composer plugin file. +# AUTHOR: Daniel Gomes (me@danielcsgomes.com) +# VERSION: 1.0.0 +# ------------------------------------------------------------------------------ + +# Composer basic command completion +_composer_get_command_list () { + composer --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' +} + +_composer () { + if [ -f composer.json ]; then + compadd `_composer_get_command_list` + fi +} + +compdef _composer composer + +# Aliases +alias c='composer' +alias csu='composer self-update' +alias cu='composer update' +alias ci='composer install' +alias ccp='composer create-project' + +alias cget='curl -s https://getcomposer.org/installer | php' \ No newline at end of file From 9365fd03f62854c48bc06388542ba4933eb067db Mon Sep 17 00:00:00 2001 From: Daniel Gomes Date: Fri, 5 Oct 2012 21:14:44 +0100 Subject: [PATCH 33/35] added a comment to the composer installation alias --- plugins/composer/composer.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index a054ae2c..c9b762d0 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -25,4 +25,5 @@ alias cu='composer update' alias ci='composer install' alias ccp='composer create-project' +# install composer in the current directory alias cget='curl -s https://getcomposer.org/installer | php' \ No newline at end of file From a97e117281fa495bf13b7aa4179647cb9c7f5c01 Mon Sep 17 00:00:00 2001 From: Ian Chesal Date: Mon, 8 Oct 2012 15:42:27 -0400 Subject: [PATCH 34/35] URL Tools Plugin * Added urlencode -- alias to encode URLs from the command line using Python * Added urldecode -- alias to decode URLs from the command line using Python --- plugins/urltools/urltools.plugin.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/urltools/urltools.plugin.zsh diff --git a/plugins/urltools/urltools.plugin.zsh b/plugins/urltools/urltools.plugin.zsh new file mode 100644 index 00000000..0d29314d --- /dev/null +++ b/plugins/urltools/urltools.plugin.zsh @@ -0,0 +1,9 @@ +# URL Tools +# Adds handy command line aliases useful for dealing with URLs +# +# Taken from: +# http://ruslanspivak.com/2010/06/02/urlencode-and-urldecode-from-a-command-line/ + +alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' + +alias urldecode='python -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' \ No newline at end of file From a0bcbfb111cc28c7e3e8320f001d28297614698e Mon Sep 17 00:00:00 2001 From: Dominik Bamberger Date: Tue, 9 Oct 2012 08:47:18 +0200 Subject: [PATCH 35/35] make README reflect latest changes --- plugins/zeus/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/zeus/README.md b/plugins/zeus/README.md index 2cb85cec..4409943f 100644 --- a/plugins/zeus/README.md +++ b/plugins/zeus/README.md @@ -28,14 +28,14 @@ * `zt` aliases `zeus test` * `zest` aliases `zeus test` -* `zu` aliases `zeus test/units/*` -* `zunits` aliases `zeus test/units/*` +* `zu` aliases `zeus test test/unit/*` +* `zunits` aliases `zeus test test/unit/*` -* `zf` aliases `zeus test/functional/*` -* `zunctional` aliases `zeus test/functional/*` +* `zf` aliases `zeus test test/functional/*` +* `zunctional` aliases `zeus test test/functional/*` -* `za` aliases `zeus test test/units/*; zeus test test/functional/; zeus cucumber` -* `zall` aliases `zeus test test/units/*; zeus test test/functional/; zeus cucumber` +* `za` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber` +* `zall` aliases `zeus test test/unit/*; zeus test test/functional/; zeus cucumber` * `zsw` aliases `rm .zeus.sock` * `zweep` aliases `rm .zeus.sock`