From 83ff301d960015a161b94177dec061179de754b5 Mon Sep 17 00:00:00 2001 From: Matthew Winter <33818+wintermi@users.noreply.github.com> Date: Sat, 13 May 2023 12:36:28 +1000 Subject: [PATCH 1/4] feat: update to latest github actions version --- .github/workflows/pre-commit.yml | 4 ++-- .github/workflows/test-suite.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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: | From eb1e47c0112d229372182c3c83da312eeddc2135 Mon Sep 17 00:00:00 2001 From: Matthew Winter <33818+wintermi@users.noreply.github.com> Date: Sat, 13 May 2023 12:42:46 +1000 Subject: [PATCH 2/4] feat: move default .zshrc to a template file --- install.zsh | 19 ++++++++----------- templates/default-zshrc | 10 ++++++++++ zap.zsh | 19 ++++++++----------- 3 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 templates/default-zshrc diff --git a/install.zsh b/install.zsh index da4e3a2..67ca961 100755 --- a/install.zsh +++ b/install.zsh @@ -19,6 +19,11 @@ 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 if the current .zshrc file exists if [ -f "$ZSHRC" ]; then # Move the current .zshrc file to the new filename @@ -29,16 +34,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 default template to the .zshrc file + cat "$ZAP_DIR/templates/default-zshrc" >> "$ZSHRC" echo " Zapped" echo "Find more plugins at http://zapzsh.org" @@ -50,4 +47,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 From 50fe23bc7bdb621d3c4ea6166e94e3f637fef2a2 Mon Sep 17 00:00:00 2001 From: Matthew Winter <33818+wintermi@users.noreply.github.com> Date: Sat, 13 May 2023 13:11:32 +1000 Subject: [PATCH 3/4] feat: add a check to see if the .zshrc template file exists --- install.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.zsh b/install.zsh index 67ca961..7cd8899 100755 --- a/install.zsh +++ b/install.zsh @@ -34,7 +34,11 @@ main() { touch "$ZSHRC" fi - # Write out the default template to the .zshrc file + # Check the .zshrc template exists and write out to the .zshrc file + if [ ! -f "$ZAP_DIR/templates/default-zshrc" ]; then + echo "Template .zshrc file was not found in Zap installation" + return 2 + fi cat "$ZAP_DIR/templates/default-zshrc" >> "$ZSHRC" echo " Zapped" From 0c261d6eb449d9c3c2bbe362c0f30a2c5cc6a6bd Mon Sep 17 00:00:00 2001 From: Matthew Winter <33818+wintermi@users.noreply.github.com> Date: Sat, 13 May 2023 13:18:16 +1000 Subject: [PATCH 4/4] fix: check the .zshrc template exists before any changes to the .zshrc file are made --- install.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/install.zsh b/install.zsh index 7cd8899..02fb0c7 100755 --- a/install.zsh +++ b/install.zsh @@ -24,6 +24,12 @@ main() { 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 @@ -34,11 +40,7 @@ main() { touch "$ZSHRC" fi - # Check the .zshrc template exists and write out to the .zshrc file - if [ ! -f "$ZAP_DIR/templates/default-zshrc" ]; then - echo "Template .zshrc file was not found in Zap installation" - return 2 - fi + # Write out the .zshrc template to the .zshrc cat "$ZAP_DIR/templates/default-zshrc" >> "$ZSHRC" echo " Zapped"