diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..b78cd484 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# https://help.github.com/articles/about-codeowners/ + +* @zplug/maintainer diff --git a/.github/ISSUE_TEMPLATE/Bug_report.md b/.github/ISSUE_TEMPLATE/Bug_report.md new file mode 100644 index 00000000..ad802f9f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Bug_report.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: Create a report to help us improve + +--- + + + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Env (please complete the following information):** + - `zplug version`: + - `zsh --version`: + - `uname -a`: + +**Minimal zshrc (with less than 30 lines)** + +Create a minimal reproducing set of configurations for this issue. Please remove all unnecessary parts! + +```zsh +source ~/.zplug/init.zsh + +#zplug "foo/bar", tag:baz +#zplug "... + +if zplug check || zplug install; then + zplug load --verbose +fi +``` + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/Feature_request.md b/.github/ISSUE_TEMPLATE/Feature_request.md new file mode 100644 index 00000000..53842951 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.gitignore b/.gitignore index eb3528e8..b339edab 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ zcompdump.zwc # OS X .DS_Store **/.DS_Store + +.ssh diff --git a/.zshrc b/.zshrc new file mode 100644 index 00000000..cec2f705 --- /dev/null +++ b/.zshrc @@ -0,0 +1,22 @@ +# Sample zshrc + +ZPLUG_SUDO_PASSWORD= +ZPLUG_PROTOCOL=ssh + +source $HOME/.zplug/init.zsh + +zplug "b4b4r07/ultimate", as:theme +zplug 'b4b4r07/zplug-doctor', lazy:yes +zplug 'b4b4r07/zplug-cd', lazy:yes +zplug 'b4b4r07/zplug-rm', lazy:yes + +if ! zplug check --verbose; then + printf "Install? [y/N]: " + if read -q; then + echo; zplug install + fi + echo +fi + +zplug load + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..364770b2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:xenial + +RUN apt update && apt-get install -y software-properties-common && \ + add-apt-repository -y ppa:jonathonf/vim && \ + apt-get update && apt-get install -y locales build-essential openssh-server git vim zsh tmux curl unzip sudo && \ + rm -rf /var/lib/apt/lists/* + +RUN locale-gen en_US.UTF-8 + +RUN groupadd -g 1000 zplug && \ + useradd -g zplug -G sudo -m -s /bin/zsh zplug && \ + echo 'zplug:zplug' | chpasswd + +# .ssh dir needs to be copied from your home +ADD .ssh /home/zplug/.ssh + +ADD . /home/zplug/.zplug + +RUN chown -R zplug:zplug /home/zplug +RUN chmod 600 /home/zplug/.ssh/id_rsa + +USER zplug +WORKDIR /home/zplug + +CMD ["/bin/zsh"] diff --git a/README.md b/README.md index 412965da..a89b5603 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,10 @@ latest | stable ### The best way ```console -$ curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh +$ curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh | zsh ``` -If you wonder this installation, please check it out: - -- [zplug/installer](https://github.com/zplug/installer/blob/master/installer.zsh) +Curious about the installation script? Check it out at [zplug/installer](https://github.com/zplug/installer/blob/master/installer.zsh). ### Using [Homebrew](https://github.com/Homebrew/brew) (OS X) @@ -253,8 +251,8 @@ All that's left is to run `zplug update`. | `rename-to` | Specify the filename you want to rename the command to (use this only with `as:command`) | *filename* (-) | `rename-to:fzf` | | `dir` | Installed directory of the package | **READ ONLY** | `dir:/path/to/user/repo` | | `if` | Specify the conditions under which to install and use the package | *boolean* (-) | `if:"[ -d ~/.zsh ]"` | -| `hook-build` | Commands to after installation/update | *commands* (-) | `hook-build:"make install"` | -| `hook-load` | Commands to after loading | *commands* (-) | `hook-load:"echo 'Loaded!'"` | +| `hook-build` | Commands to run after installation/update | *commands* (-) | `hook-build:"make install"` | +| `hook-load` | Commands to run after loading | *commands* (-) | `hook-load:"echo 'Loaded!'"` | | `frozen` | Do not update unless explicitly specified | truthy,falsy (false) | `frozen:1` | | `on` | Load this package only if a different package is installed | *package* | `on:user/repo` | | `defer` | Defers the loading of a package. If the value is 2 or above, zplug will source the plugin after `compinit` (see also [#26](https://github.com/zplug/zplug/issues/26)) | 0..3 (0) | `defer:2` | @@ -350,6 +348,14 @@ Defaults to `$ZPLUG_HOME/repos`. You can change where the repositories are clone Defaults to `''`. You can set sudo password for zplug's `hook-build` tag. However, this variable should not be managed in dotfiles and so on. +#### `ZPLUG_LOG_LOAD_SUCCESS` + +Defaults to `false`. If true, zplug spit the log about its success operation out to file (you can see it with `zplug --log`). + +#### `ZPLUG_LOG_LOAD_FAILURE` + +Defaults to `false`. If true, zplug spit the log about its failure operation out to file (you can see it with `zplug --log`). + ```zsh # your .zshrc source ~/.zshrc_secret diff --git a/autoload/commands/__help__ b/autoload/commands/__help__ new file mode 100644 index 00000000..a36657e0 --- /dev/null +++ b/autoload/commands/__help__ @@ -0,0 +1,89 @@ +#!/usr/bin/env zsh +# Description: +# Display the help message + +local f arg +local -a fs args + +local -A opts cmds +local obj opt cmd +local -i max=0 + +while (( $# > 0 )) +do + arg="$1" + case "$arg" in + -*|--*) + break + ;; + "") + ;; + *) + fs=( "$(echo $ZPLUG_HOME/doc/man/man(1|5)/(zplug-|)${arg}.(1|5)(N))" ) + # Non-existing man page + if [[ $fs[1] == "" ]]; then + __zplug::io::print::f \ + --die \ + --zplug \ + "$arg: no such subcommand or tag\n" + return 1 + fi + # List all hits pages + for f in "${fs[@]}" + do + if [[ -f $f ]]; then + args+=( "$f" ) + fi + done + ;; + esac + shift +done + +if (( $#args > 0 )); then + man "${args[@]}" + return $status +fi + +# Measure max length +{ + cmds=( "${(kv)_zplug_commands[@]}" ) + for opt in "${(k)_zplug_options[@]}" + do + opts[--$opt]="$_zplug_options[$opt]" + done + + for obj in "${(k)cmds[@]}" "${(k)opts[@]}" + do + if (( $#obj > $max )); then + max=$#obj + fi + done +} + +# Help message format +{ + printf "usage: zplug [OPTIONS] [COMMANDS [options] [args]]\n" + printf " zplug is a next-generation plugin manager for zsh\n" + + for obj in \ + OPTIONS "${(k)opts[@]}" \ + COMMANDS "${(k)cmds[@]}"; do \ + case "$obj" in + OPTIONS | COMMANDS) + printf "\n$obj:\n" + ;; + *) + desc="(None)" + [[ -n $opts[$obj] ]] && desc="$opts[$obj]" + [[ -n $cmds[$obj] ]] && desc="$cmds[$obj]" + printf " %-${max}s %s\n" \ + "$obj" \ + "$desc" + ;; + esac + done + printf "\n" +} >&2 + +return 0 diff --git a/autoload/options/__help__ b/autoload/options/__help__ index 766cafce..a36657e0 100644 --- a/autoload/options/__help__ +++ b/autoload/options/__help__ @@ -86,4 +86,4 @@ fi printf "\n" } >&2 -return 1 +return 0 diff --git a/autoload/zplug b/autoload/zplug index cb158725..f7912767 100644 --- a/autoload/zplug +++ b/autoload/zplug @@ -7,7 +7,7 @@ case "$arg" in __zplug::core::options::parse "$argv[@]" ;; - check | install | update | list | clean | status | clear | load | info) + check | install | update | list | clean | status | clear | load | info | help) shift __zplug::core::core::run_interfaces \ "$arg" \ diff --git a/base/base/base.zsh b/base/base/base.zsh index bb037035..3ae8328b 100644 --- a/base/base/base.zsh +++ b/base/base/base.zsh @@ -107,7 +107,7 @@ __zplug::base::base::git_version() fi __zplug::base::base::version_requirement \ - ${(M)${(z)"$(git --version)"}:#[0-9]*[0-9]} ">" "${@:?}" + ${(M)${(z)"$(git --version|head -1)"}:#[0-9]*[0-9]} ">" "${@:?}" return $status } diff --git a/base/core/core.zsh b/base/core/core.zsh index e7895cc9..4e2624fb 100644 --- a/base/core/core.zsh +++ b/base/core/core.zsh @@ -132,7 +132,8 @@ __zplug::core::core::prepare() # Add to the PATH path=( - ${ZPLUG_BIN:-"$ZPLUG_ROOT/bin"} + ${ZPLUG_ROOT:+"$ZPLUG_ROOT/bin"} + ${ZPLUG_BIN:-${ZPLUG_HOME:+"$ZPLUG_HOME/bin"}} "$path[@]" ) @@ -170,6 +171,8 @@ __zplug::core::core::variable() typeset -gx ZPLUG_SUDO_PASSWORD typeset -gx ZPLUG_ERROR_LOG=${ZPLUG_ERROR_LOG:-$ZPLUG_HOME/.error_log} + typeset -gx ZPLUG_LOG_LOAD_SUCCESS=${ZPLUG_LOG_LOAD_SUCCESS:-false} + typeset -gx ZPLUG_LOG_LOAD_FAILURE=${ZPLUG_LOG_LOAD_FAILURE:-false} typeset -gx ZPLUG_BIN=${ZPLUG_BIN:-$ZPLUG_HOME/bin} typeset -gx ZPLUG_CACHE_DIR=${ZPLUG_CACHE_DIR:-$ZPLUG_HOME/cache} diff --git a/base/core/load.zsh b/base/core/load.zsh index 049716c7..bddfffec 100644 --- a/base/core/load.zsh +++ b/base/core/load.zsh @@ -3,8 +3,8 @@ __zplug::core::load::prepare() setopt nomonitor zstyle ':zplug:core:load' 'verbose' no - __zplug::io::file::rm_touch "$_zplug_load_log[success]" - __zplug::io::file::rm_touch "$_zplug_load_log[failure]" + $ZPLUG_LOG_LOAD_SUCCESS && __zplug::io::file::rm_touch "$_zplug_load_log[success]" + $ZPLUG_LOG_LOAD_FAILURE && __zplug::io::file::rm_touch "$_zplug_load_log[failure]" } __zplug::core::load::from_cache() @@ -121,9 +121,9 @@ __zplug::core::load::as_plugin() if [[ -n $hook ]]; then eval ${=hook} fi - __zplug::job::handle::flock "$_zplug_load_log[success]" "$repo" + $ZPLUG_LOG_LOAD_SUCCESS && __zplug::job::handle::flock "$_zplug_load_log[success]" "$repo" else - __zplug::job::handle::flock "$_zplug_load_log[failure]" "$repo" + $ZPLUG_LOG_LOAD_FAILURE && __zplug::job::handle::flock "$_zplug_load_log[failure]" "$repo" fi return $status_code @@ -176,9 +176,9 @@ __zplug::core::load::as_command() if [[ -n $hook ]]; then eval ${=hook} fi - __zplug::job::handle::flock "$_zplug_load_log[success]" "$repo" + $ZPLUG_LOG_LOAD_SUCCESS && __zplug::job::handle::flock "$_zplug_load_log[success]" "$repo" else - __zplug::job::handle::flock "$_zplug_load_log[failure]" "$repo" + $ZPLUG_LOG_LOAD_FAILURE && __zplug::job::handle::flock "$_zplug_load_log[failure]" "$repo" fi return $status_code diff --git a/build.sh b/build.sh new file mode 100755 index 00000000..2065381c --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +cp -R ~/.ssh .ssh + +docker build -t zplug -f Dockerfile . + +rm -rf .ssh diff --git a/misc/zshrc b/misc/zshrc index 11509d23..293c1b8f 100644 --- a/misc/zshrc +++ b/misc/zshrc @@ -22,7 +22,7 @@ zplug clear as:command, \ use:"bin/{histuniq,color}" # theme - zplug "S1cK94/minimal", \ + zplug "b4b4r07/ultimate", \ as:theme tests+=( diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..37fedfdd --- /dev/null +++ b/run.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +set -e + +zshrc_path=${1:-${PWD}/.zshrc} + +docker run --rm -v $zshrc_path:/home/zplug/.zshrc -it zplug