diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 4638d6a..b189b14 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -9,8 +9,8 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.0 - - uses: actions/setup-python@v4.5.0 + - uses: actions/checkout@v3.5.2 + - uses: actions/setup-python@v4.6.0 with: python-version: "3.10.11" - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index d33f751..7a15dfa 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -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: | diff --git a/install.zsh b/install.zsh index da4e3a2..02fb0c7 100755 --- a/install.zsh +++ b/install.zsh @@ -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 @@ -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" @@ -50,4 +53,4 @@ main $@ [[ $? -eq 0 ]] && source "${ZDOTDIR:-$HOME}/.zshrc" || return -# vim: ft=zsh ts=4 et +# vim: ft=zsh ts=4 et \ No newline at end of file diff --git a/templates/default-zshrc b/templates/default-zshrc new file mode 100644 index 0000000..a8b508d --- /dev/null +++ b/templates/default-zshrc @@ -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 \ No newline at end of file diff --git a/zap.zsh b/zap.zsh index a1e31f3..1d2ded9 100644 --- a/zap.zsh +++ b/zap.zsh @@ -123,15 +123,15 @@ function _zap_help() { Usage: zap [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() { @@ -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 \ No newline at end of file