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

fix: a bunch of modifications #49

Merged
merged 4 commits into from
Nov 12, 2022
Merged
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
18 changes: 7 additions & 11 deletions zap.zsh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
# shellcheck disable=SC1090

export ZAP_DIR="$HOME/.local/share/zap"
export ZAP_PLUGIN_DIR="$ZAP_DIR/plugins"
Expand All @@ -8,23 +9,17 @@ else
export ZAP_ZSHRC=$ZDOTDIR/.zshrc
fi

_try_source() {
# shellcheck disable=SC1090
[ -f "$1" ] && source "$1"
}

plug() {
plugin="$1"
if [ -f "$plugin" ]; then
source "$plugin"
else
local full_plugin_name="$1"
local git_ref="$2"
local plugin_name=$(echo "$full_plugin_name" | cut -d "/" -f 2)
local plugin_name=$(basename "$plugin")
local plugin_dir="$ZAP_PLUGIN_DIR/$plugin_name"
if [ ! -d "$plugin_dir" ]; then
echo "🔌$plugin_name"
git clone "https://github.com/${full_plugin_name}.git" "$plugin_dir" > /dev/null 2>&1
git clone "https://github.com/${plugin}.git" "$plugin_dir" > /dev/null 2>&1
if [ -n "$git_ref" ]; then
git -C "$plugin_dir" checkout "$git_ref" > /dev/null 2>&1
fi
Expand All @@ -34,9 +29,10 @@ plug() {
fi
echo -e "\e[1A\e[K⚡$plugin_name"
fi
_try_source "$plugin_dir/$plugin_name.plugin.zsh"
_try_source "$plugin_dir/$plugin_name.zsh"
_try_source "$plugin_dir/$plugin_name.zsh-theme"
local full_path="$plugin_dir/$plugin$name"
[[ -f "$full_path.plugin.zsh" ]] && source "$full_path.plugin.zsh"
[[ -f "$full_path.zsh" ]] && source "$full_path.zsh"
[[ -f "$full_path.zsh-theme" ]] && source "$full_path.zsh-theme"
fi
}

Expand Down