Skip to content

Commit

Permalink
feat: move default .zshrc to a template file
Browse files Browse the repository at this point in the history
  • Loading branch information
wintermi committed May 13, 2023
1 parent 83ff301 commit eb1e47c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
19 changes: 8 additions & 11 deletions install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -50,4 +47,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 eb1e47c

Please sign in to comment.