Skip to content

Commit

Permalink
Merge pull request #147 from zap-zsh/wintermi
Browse files Browse the repository at this point in the history
feat: move to use a .zshrc template file
  • Loading branch information
wintermi authored May 13, 2023
2 parents c74c3cc + 0c261d6 commit 0272b7c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].0
- uses: actions/setup-python@v4.5.0
- uses: actions/[email protected].2
- uses: actions/setup-python@v4.6.0
with:
python-version: "3.10.11"
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- ubuntu-latest
- macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3.5.2
- name: Install ZSH
if: ${{ runner.os == 'Linux' }}
run: |
Expand Down
25 changes: 14 additions & 11 deletions install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ main() {
rm -rf "$ZAP_DIR"
}

# Get the branch of the Zap ZSH repository to clone
[[ $1 == "--branch" || $1 == "-b" && -n $2 ]] && local BRANCH="$2"

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

# Check the .zshrc template exists
if [ ! -f "$ZAP_DIR/templates/default-zshrc" ]; then
echo "Template .zshrc file was not found in Zap installation"
return 2
fi

# Check if the current .zshrc file exists
if [ -f "$ZSHRC" ]; then
# Move the current .zshrc file to the new filename
Expand All @@ -29,16 +40,8 @@ main() {
touch "$ZSHRC"
fi

echo "# Created by Zap installer" >> "$ZSHRC"
echo '[ -f "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh" ] && source "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh"' >> "$ZSHRC"
echo 'plug "zsh-users/zsh-autosuggestions"' >> "$ZSHRC"
echo 'plug "zap-zsh/supercharge"' >> "$ZSHRC"
echo 'plug "zap-zsh/zap-prompt"' >> "$ZSHRC"
echo 'plug "zsh-users/zsh-syntax-highlighting"' >> "$ZSHRC"

[[ $1 == "--branch" || $1 == "-b" && -n $2 ]] && local BRANCH="$2"

git clone --depth 1 -b "${BRANCH:-master}" https://github.com/zap-zsh/zap.git "$ZAP_DIR" > /dev/null 2>&1 || { echo "❌ Failed to install Zap" && return 2 }
# Write out the .zshrc template to the .zshrc
cat "$ZAP_DIR/templates/default-zshrc" >> "$ZSHRC"

echo " Zapped"
echo "Find more plugins at http://zapzsh.org"
Expand All @@ -50,4 +53,4 @@ main $@

[[ $? -eq 0 ]] && source "${ZDOTDIR:-$HOME}/.zshrc" || return

# vim: ft=zsh ts=4 et
# vim: ft=zsh ts=4 et
10 changes: 10 additions & 0 deletions templates/default-zshrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Created by Zap installer
[ -f "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh" ] && source "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh"
plug "zsh-users/zsh-autosuggestions"
plug "zap-zsh/supercharge"
plug "zap-zsh/zap-prompt"
plug "zsh-users/zsh-syntax-highlighting"

# Load and initialise completion system
autoload -Uz compinit
compinit
19 changes: 8 additions & 11 deletions zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ function _zap_help() {
Usage: zap <command> [options]
COMMANDS:
clean Remove unused plugins
help Show this help message
list List plugins
update Update plugins
version Show version information
clean Remove unused plugins
help Show this help message
list List plugins
update Update plugins
version Show version information
OPTIONS:
update self Update Zap itself
update all Update all plugins"
update self Update Zap itself
update all Update all plugins"
}

function _zap_version() {
Expand Down Expand Up @@ -161,7 +161,4 @@ function zap() {
# 12: Failed to clone
# 13: Failed to checkout
# 14: Failed to pull
# 15: Nothing to remove



# 15: Nothing to remove

0 comments on commit 0272b7c

Please sign in to comment.