Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add git clone URL prefix variable and update documentation #124

Merged
merged 3 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/action@v3.0.0
- uses: actions/checkout@v3.5.0
- uses: actions/setup-python@v4.5.0
with:
python-version: "3.10.11"
- uses: pre-commit/action@v3.0.0
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https://github.com/lovesegfault/beautysh
rev: v6.1.0
rev: v6.2.1
hooks:
- id: beautysh
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,41 @@ zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh)
Add the following to your `.zshrc`

```zsh
# Example sourcing of files
plug "$HOME/.config/zsh/aliases.zsh"
plug "$HOME/.config/zsh/exports.zsh"

# Example install plugins
# Example install of plugins
plug "zap-zsh/supercharge"
plug "zsh-users/zsh-autosuggestions"

#Example plugin pinned to specifc commit or branch, just pass the git reference
# Example install of a plugin pinned to specifc commit or branch, just pass the git reference
plug "zsh-users/zsh-syntax-highlighting" "122dc46"

# Example theme
# Example install of a theme
plug "zap-zsh/zap-prompt"

# Example install completion
# Example install of a zsh completion
plug "esc/conda-zsh-completion"
```

You can also use `Zap` to source your custom files, like:
You can also use `Zap` to install custom plugins or source custom files present on your local filesystem. A file descriptor which points to a directory is treated as a plugin, versus a regular file. For example:

```zsh
# Example install of a local plugin
plug "$HOME/plugins/my-custom-prompt"

# Example sourcing of local files
plug "$HOME/.config/zsh/aliases.zsh"
plug "$HOME/.config/zsh/exports.zsh"
```

By default `Zap` when installing a plugin will clone a GitHub repository using a HTTPS web URL, if you require to be able to install from a private GitHub repository you can provide a different URL prefix to be used. For example, using a password-protected SSH key:

```zsh
plug "${ZDOTDIR:-$HOME}/aliases"
# Example git clone using an SSH key
export ZAP_GITHUB_PREFIX="git@"
plug "zap-zsh/private-repo"
```

:warning:_In this case the file has to be present in your system and the argument passed to `plug` has to be a file descriptor that points to a regular file. This means you actually need to specify the path to the file (absolute or using environment variables like shown above) and, if the file has an extension you must type it._<br>
For more information about that, take a look at [this issue](https://github.com/zap-zsh/zap/issues/88)
It is possible to call `plug` in any interactive shell session to source a file or to download and source a plugin for that particular session.

Is possible to call `plug` in any interactive shell session to source a file or to download and source a plugin for that particular session.<br>
:warning: If you call `plug` outside your `.zshrc` file, the plugin you sourced will not be sourced at the next shell reload.

## Commands
Expand All @@ -104,6 +111,12 @@ Zap provided commands for updating and cleaning up plugins
zap update
```

- To list all plugins you are using:

```zsh
zap list
```

- To remove plugins you are no longer using:

```zsh
Expand Down
2 changes: 1 addition & 1 deletion zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function plug() {
local git_ref="$2"
if [ ! -d "$plugin_dir" ]; then
echo "🔌 Zap is installing $plugin_name..."
git clone "https://github.com/${plugin}.git" "$plugin_dir" > /dev/null 2>&1 || { echo -e "\e[1A\e[K❌ Failed to clone $plugin_name"; return 12 }
git clone "${ZAP_GITHUB_PREFIX:-"https://"}github.com/${plugin}.git" "$plugin_dir" > /dev/null 2>&1 || { echo -e "\e[1A\e[K❌ Failed to clone $plugin_name"; return 12 }
echo -e "\e[1A\e[K⚡ Zap installed $plugin_name"
fi
[[ -n "$git_ref" ]] && { git -C "$plugin_dir" checkout "$git_ref" > /dev/null 2>&1 || { echo "❌ Failed to checkout $git_ref"; return 13 }}
Expand Down