diff --git a/lib/completion.zsh b/lib/completion.zsh index f5b292471..bbd021656 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -1,4 +1,7 @@ # fixme - the load process here seems a bit bizarre +zmodload -i zsh/complist + +WORDCHARS='' unsetopt menu_complete # do not autoselect the first completion entry unsetopt flowcontrol @@ -6,32 +9,26 @@ setopt auto_menu # show completion menu on succesive tab press setopt complete_in_word setopt always_to_end -WORDCHARS='' - -zmodload -i zsh/complist - -## case-insensitive (all),partial-word and then substring completion -if [ "x$CASE_SENSITIVE" = "xtrue" ]; then - zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - unset CASE_SENSITIVE -else - if [ "x$HYPHEN_INSENSITIVE" = "xtrue" ]; then - zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - unset HYPHEN_INSENSITIVE - else - zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' - fi -fi - -zstyle ':completion:*' list-colors '' - # should this be in keybindings? bindkey -M menuselect '^o' accept-and-infer-next-history - zstyle ':completion:*:*:*:*:*' menu select + +# case insensitive (all), partial-word and substring completion +if [[ "$CASE_SENSITIVE" = true ]]; then + zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' +else + if [[ "$HYPHEN_INSENSITIVE" = true ]]; then + zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*' + else + zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' + fi +fi +unset CASE_SENSITIVE HYPHEN_INSENSITIVE + +zstyle ':completion:*' list-colors '' zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -if [ "$OSTYPE[0,7]" = "solaris" ] -then + +if [[ "$OSTYPE" = solaris* ]]; then zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm" else zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" diff --git a/plugins/copybuffer/README.md b/plugins/copybuffer/README.md new file mode 100644 index 000000000..da138bdbd --- /dev/null +++ b/plugins/copybuffer/README.md @@ -0,0 +1,11 @@ +# `copybuffer` plugin + +This plugin binds the ctrl-o keyboard shortcut to a command that copies the text +that is currently typed in the command line ($BUFFER) to the system clipboard. + +This is useful if you type a command - and before you hit enter to execute it - want +to copy it maybe so you can paste it into a script, gist or whatnot. + +```zsh +plugins=(... copybuffer) +``` diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh new file mode 100644 index 000000000..cc205d40f --- /dev/null +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -0,0 +1,14 @@ +# copy the active line from the command line buffer +# onto the system clipboard (requires clipcopy plugin) + +copybuffer () { + if which clipcopy &>/dev/null; then + echo $BUFFER | clipcopy + else + echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." + fi +} + +zle -N copybuffer + +bindkey "^O" copybuffer diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 66dfeea9e..1366fd61b 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -228,7 +228,7 @@ __docker_get_log_options() { journald_options=("env" "labels" "tag") json_file_options=("env" "labels" "max-file" "max-size") syslog_options=("env" "labels" "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") - splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag") + splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-gzip" "splunk-gzip-level" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag") [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0 [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 @@ -434,7 +434,7 @@ __docker_complete_events_filter() { (event) local -a event_opts event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' - 'exec_start' 'export' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' + 'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') _describe -t event-filter-opts "event filter options" event_opts && ret=0 ;; @@ -792,7 +792,7 @@ __docker_node_commands() { "ls:List nodes in the swarm" "promote:Promote a node as manager in the swarm" "rm:Remove one or more nodes from the swarm" - "ps:List tasks running on a node" + "ps:List tasks running on a node, defaults to current node" "update:Update a node" ) _describe -t docker-node-commands "docker node command" _docker_node_subcommands @@ -1083,6 +1083,7 @@ __docker_service_subcommand() { "($help)*--constraint=[Placement constraints]:constraint: " "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)" "($help)*"{-e=,--env=}"[Set environment variables]:env: " + "($help)*--group-add=[Add additional user groups to the container]:group:_groups" "($help)*--label=[Service labels]:label: " "($help)--limit-cpu=[Limit CPUs]:value: " "($help)--limit-memory=[Limit Memory]:value: " @@ -1177,6 +1178,7 @@ __docker_service_subcommand() { "($help)--arg=[Service command args]:arguments: _normal" \ "($help)*--container-label-add=[Add or update container labels]:label: " \ "($help)*--container-label-rm=[Remove a container label by its key]:label: " \ + "($help)*--group-rm=[Remove previously added user groups from the container]:group:_groups" \ "($help)--image=[Service image tag]:image:__docker_repositories" \ "($help -)1:service:__docker_complete_services" && ret=0 ;; @@ -1658,7 +1660,8 @@ __docker_subcommand() { $opts_help \ "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \ "($help)--since=[Events created since this timestamp]:timestamp: " \ - "($help)--until=[Events created until this timestamp]:timestamp: " && ret=0 + "($help)--until=[Events created until this timestamp]:timestamp: " \ + "($help)--format=[Format the output using the given go template]:template: " && ret=0 ;; (exec) local state @@ -1701,7 +1704,7 @@ __docker_subcommand() { "($help -a --all)"{-a,--all}"[Show all images]" \ "($help)--digests[Show digests]" \ "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ - "($help)--format[Pretty-print containers using a Go template]:template: " \ + "($help)--format[Pretty-print images using a Go template]:template: " \ "($help)--no-trunc[Do not truncate output]" \ "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ "($help -): :__docker_repositories" && ret=0 diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6197c234b..25da03509 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -46,6 +46,7 @@ alias gapa='git add --patch' alias gb='git branch' alias gba='git branch -a' +alias gbd='git branch -d' alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbl='git blame -b -w' alias gbnm='git branch --no-merged' diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index d290c98ec..625aad949 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -172,7 +172,7 @@ function listMavenCompletions { gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test # options - -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true + -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true -DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile= # arguments -am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X diff --git a/plugins/ng/README.md b/plugins/ng/README.md new file mode 100644 index 000000000..86ad64041 --- /dev/null +++ b/plugins/ng/README.md @@ -0,0 +1,37 @@ +## NG Plugin + +This [ng plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ng) + adds completion support for Angular's CLI (named ng). + +Ng is hosted on [ng home](https://github.com/catull/angular-cli) + +It is used to generate Angular 2 app "stubs", build those apps, configure them, +test them, lint them etc. + +Ahem, "stubs" is not what Angular engineers refer to the items ng can generate +for you. + +"Stubs" can be any one of: +- class +- component +- directive +- enum +- module +- pipe +- route +- service + +At the moment, `ng completion` creates a very rough completion for Zsh and +Bash. + +It is missing most of the options and a few arguments. +In future, this plugin may be shortened to simply being + +```zsh +eval `ng completion` +``` + +There is hope this materialises in the 21st century. + +### CONTRIBUTOR + - Carlo Dapor ([catull](https://github.com/catull)) diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh new file mode 100644 index 000000000..2488bc230 --- /dev/null +++ b/plugins/ng/ng.plugin.zsh @@ -0,0 +1,77 @@ + +ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test v version -h --help' + +_ng_completion () { + local words cword opts + read -Ac words + read -cn cword + let cword-=1 + + case $words[cword] in + addon ) + opts='-b --blueprint -d -dir --directory --dry-run -sb --skip-bower -sg --skip-git -sn --skip-npm -v --verbose' + ;; + + asset-sizes ) + opts='-o --output-path' + ;; + + b | build ) + opts='--environment --output-path --suppress-sizes --target --watch --watcher -dev -e -prod' + ;; + + d | destroy ) + opts='--dry-run --verbose --pod --classic --dummy --in-repo --in-repo-addon -d -v -p -c -dum -id -ir' + ;; + + g | generate ) + opts='class component directive enum module pipe route service --generate -d --dry-run --verbose -v --pod -p --classic -c --dummy -dum -id --in-repo --in-repo-addon -ir' + ;; + + gh-pages:deploy | github-pages:deploy ) + opts='--environment --gh-token --gh-username --skip-build --user-page --message' + ;; + + h | help | -h | --help) + opts='--json --verbose -v' + ;; + + init ) + opts='--blueprint --dry-run --link-cli --mobile --name --prefix --skip-bower --skip-npm --source-dir --style --verbose -b -d -lc -n -p -sb -sd -sn -v' + ;; + + new ) + opts='--blueprint --directory --dry-run --link-cli --mobile --prefix --skip-bower --skip-git --skip-npm --source-dir --style --verbose -b -d -dir -lc -p -sb -sd -sg -sn -v' + ;; + + s | serve | server ) + opts='--environment --host --insecure-proxy --inspr --live-reload --live-reload-base-url --live-reload-host --live-reload-live-css --live-reload-port --output-path --port --proxy --ssl --ssl-cert --ssl-key --target --watcher -H -dev -e -lr -lrbu -lrh -lrp -op -out -p -pr -prod -pxy -t -w' + ;; + + set ) + opts='--global -g' + ;; + + t | test ) + opts='--browsers --colors --config-file --environment --filter --host --launch --log-level --module --path --port --query --reporter --server --silent --test-page --test-port --watch -H -c -cf -e -f -m -r -s -tp -w' + ;; + + v | version ) + opts='--verbose' + ;; + + ng ) + opts=$ng_opts + ;; + + * ) + opts='' + ;; + esac + + setopt shwordsplit + reply=($opts) + unset shwordsplit +} + +compctl -K _ng_completion ng diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 02e4f3e93..43aedc36d 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -32,6 +32,12 @@ alias npmE='PATH="$(npm bin)":"$PATH"' # Check which npm modules are outdated alias npmO="npm outdated" +# Check package versions +alias npmV="npm -v" + +# List packages +alias npmL="npm list" + # Run npm start alias npmst="npm start" diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh index 81f56d577..7cdebab7f 100644 --- a/plugins/perms/perms.plugin.zsh +++ b/plugins/perms/perms.plugin.zsh @@ -6,10 +6,10 @@ ### Aliases # Set all files' permissions to 644 recursively in a directory -alias set644='find . -type f -print0 | xargs -0 chmod 644' +alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644' # Set all directories' permissions to 755 recursively in a directory -alias set755='find . -type d -print0 | xargs -0 chmod 755' +alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755' ### Functions @@ -63,14 +63,14 @@ EOF exit_status=0; if [[ $use_slow == true ]]; then # Process directories first so non-traversable ones are fixed as we go - find "$target" -type d -exec chmod $chmod_opts 755 {} \; + find "$target" -type d ! -perm 755 -exec chmod $chmod_opts 755 {} \; if [[ $? != 0 ]]; then exit_status=$?; fi - find "$target" -type f -exec chmod $chmod_opts 644 {} \; + find "$target" -type f ! -perm 644 -exec chmod $chmod_opts 644 {} \; if [[ $? != 0 ]]; then exit_status=$?; fi else - find "$target" -type d -print0 | xargs -0 chmod $chmod_opts 755 + find "$target" -type d ! -perm 755 -print0 | xargs -0 chmod $chmod_opts 755 if [[ $? != 0 ]]; then exit_status=$?; fi - find "$target" -type f -print0 | xargs -0 chmod $chmod_opts 644 + find "$target" -type f ! -perm 644 -print0 | xargs -0 chmod $chmod_opts 644 if [[ $? != 0 ]]; then exit_status=$?; fi fi echo "Complete" diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index e532639b5..c8974b5f4 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -36,6 +36,7 @@ alias -g RET='RAILS_ENV=test' # Rails aliases alias rc='rails console' +alias rcs='rails console --sandbox' alias rd='rails destroy' alias rdb='rails dbconsole' alias rg='rails generate' diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index 15e657859..c12ce047f 100644 --- a/plugins/xcode/README.md +++ b/plugins/xcode/README.md @@ -26,7 +26,7 @@ plugins=(... xcode) ### `xc` -Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. +Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files. Returns 1 if it didn't find any relevant files. ### `simulator` diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index 0a2fa0839..f711c39fb 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -7,10 +7,19 @@ alias xcsel='sudo xcode-select --switch' # source: http://gist.github.com/subdigital/5420709 function xc { local xcode_proj - xcode_proj=(*.{xcworkspace,xcodeproj}(N)) + if [[ $# == 0 ]]; then + xcode_proj=(*.{xcworkspace,xcodeproj}(N)) + else + xcode_proj=($1/*.{xcworkspace,xcodeproj}(N)) + fi + if [[ ${#xcode_proj} -eq 0 ]]; then - echo "No xcworkspace/xcodeproj file found in the current directory." + if [[ $# == 0 ]]; then + echo "No xcworkspace/xcodeproj file found in the current directory." + else + echo "No xcworkspace/xcodeproj file found in $1." + fi return 1 else echo "Found ${xcode_proj[1]}" diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index da1f9b6e6..07546fd34 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -86,7 +86,7 @@ prompt_context() { # Git: branch/detached head, dirty status prompt_git() { - + (( $+commands[git] )) || return local PL_BRANCH_CHAR () { local LC_ALL="" LC_CTYPE="en_US.UTF-8" @@ -127,6 +127,28 @@ prompt_git() { fi } +prompt_bzr() { + (( $+commands[bzr] )) || return + if (bzr status >/dev/null 2>&1); then + status_mod=`bzr status | head -n1 | grep "modified" | wc -m` + status_all=`bzr status | head -n1 | wc -m` + revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` + if [[ $status_mod -gt 0 ]] ; then + prompt_segment yellow black + echo -n "bzr@"$revision "✚ " + else + if [[ $status_all -gt 0 ]] ; then + prompt_segment yellow black + echo -n "bzr@"$revision + + else + prompt_segment green black + echo -n "bzr@"$revision + fi + fi + fi +} + prompt_hg() { (( $+commands[hg] )) || return local rev status @@ -198,6 +220,7 @@ build_prompt() { prompt_context prompt_dir prompt_git + prompt_bzr prompt_hg prompt_end } diff --git a/themes/peepcode.zsh-theme b/themes/peepcode.zsh-theme index 9dc58294a..b6dfa6870 100644 --- a/themes/peepcode.zsh-theme +++ b/themes/peepcode.zsh-theme @@ -41,10 +41,4 @@ PROMPT=' %~ ${smiley} %{$reset_color%}' -if [[ -d ~/.rvm ]] && [[ -e ~/.rvm/bin/rvm-prompt ]]; then - rvm_prompt='$(~/.rvm/bin/rvm-prompt)' -else - rvm_prompt='' -fi - -RPROMPT='%{$fg[white]%} $rvm_prompt$(git_prompt)%{$reset_color%}' +RPROMPT='%{$fg[white]%} $(ruby_prompt_info)$(git_prompt)%{$reset_color%}'