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

feat: move to use a .zshrc template file #147

Merged
merged 4 commits into from
May 13, 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 .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/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
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