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

Massive refactor and a bug fix #102

Merged
merged 20 commits into from
Jan 16, 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
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[*.*sh]
shell_variant = bash
[*.zsh]
shell_variant = zsh
indent_style = space
indent_size = 4
space_redirects = true
32 changes: 23 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<div align="center">

![zap_logo](https://user-images.githubusercontent.com/29136904/202043505-8fda8d1e-3669-463b-a0c9-38c367ffb753.png)
Expand All @@ -7,7 +6,6 @@

---


<div align="center">

<p>
Expand Down Expand Up @@ -43,15 +41,17 @@
## Install

```sh
sh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.sh)
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh)
```
To install a specific branch of a plugin, you can pass the `--branch` flag to the install.sh script, followed by the name of the branch you want to install:

To install a specific branch of Zap, you can pass the `--branch` flag to the `install.zsh` script, followed by the name of the branch you want to install:

```sh
sh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.sh) --branch release-0.1
zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh) --branch release-0.1
```

**Zap works on Linux, macOS, Windows (within WSL), Android (within Termux)**

## Example usage

Add the following to your `.zshrc`
Expand All @@ -60,7 +60,9 @@ Add the following to your `.zshrc`
# Example install plugins
plug "zap-zsh/supercharge"
plug "zsh-users/zsh-autosuggestions"
plug "zsh-users/zsh-syntax-highlighting"

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

# Example theme
plug "zap-zsh/zap-prompt"
Expand All @@ -69,20 +71,32 @@ plug "zap-zsh/zap-prompt"
plug "esc/conda-zsh-completion"
```

You can also use `Zap` to source your custom files, like:

```sh
plug "${ZDOTDIR:-$HOME}/aliases"
```

: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)

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

Zap provided commands for updating and cleaning up plugins

- To update plugins or Zap:

```sh
zap --update
zap update
```

- To remove plugins you are no longer using:

```sh
zap --clean
zap clean
```

## Uninstall
Expand Down
12 changes: 7 additions & 5 deletions completion/_zap
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#compdef zap

_arguments -C -s \
"(-)"{-h,--help}"[Show help information]" \
"(-)"{-v,--version}"[Show version information]" \
"(-)"{-u,--update}"[Update plugins]" \
"(-)"{-c,--clean}"[Remove unused plugins]" \
local -a subcmds=(
"clean:Remove unused plugins"
"help:Show help informations"
"update:Update plugins"
"version:Show version information"
)
_describe 'zap' subcmds
7 changes: 0 additions & 7 deletions doc.txt

This file was deleted.

27 changes: 0 additions & 27 deletions install.sh

This file was deleted.

28 changes: 28 additions & 0 deletions install.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env zsh

main() {
local ZAP_DIR="$HOME/.local/share/zap"
local ZSHRC="${ZDOTDIR:-$HOME}/.zshrc"
[[ $1 == "--branch" || $1 == "-b" && -n $2 ]] && local BRANCH="$2"

# check if ZAP_DIR already exists
[[ -d "$ZAP_DIR" ]] && { echo "Zap is already installed in '$ZAP_DIR'!" && read -q "res?Reinstall Zap? [y/N] "; echo "" }
[[ "$res" == "y" ]] && { echo "Reinstalling Zap..." && rm -rf "$ZAP_DIR" } || return 0

git clone -b "${BRANCH:-master}" https://github.com/zap-zsh/zap.git "$ZAP_DIR" > /dev/null 2>&1 || { echo "❌ Failed to install Zap" && return 2 }
mkdir -p "$ZAP_DIR/plugins"

# @formatter:off
if ! grep -q '[ -f "$HOME/.local/share/zap/zap.zsh" ] && source "$HOME/.local/share/zap/zap.zsh"' "$ZSHRC"; then
sed -i.old '1 i\
[ -f "$HOME/.local/share/zap/zap.zsh" ] && source "$HOME/.local/share/zap/zap.zsh"' "$ZSHRC"
fi
# @formatter:on

echo " Zapped"
return 0
}

main $@

# vim: ft=zsh ts=4 et
Loading