This repository was archived by the owner on Mar 28, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathsetup-zsh
More file actions
executable file
·63 lines (53 loc) · 1.95 KB
/
Copy pathsetup-zsh
File metadata and controls
executable file
·63 lines (53 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "$SCRIPT_DIR/lib/helpers.sh"
source "$SCRIPT_DIR/lib/backup.sh"
DOTFILES_DIR="$HOME/.local/share/dotfiles"
# Setup zsh
log_info "Setting zsh as default shell..."
ZSH_PATH=/usr/bin/zsh
CURRENT_SHELL=$(getent passwd $USER | cut -d: -f7)
if [ "$CURRENT_SHELL" != "$ZSH_PATH" ]; then
sudo chsh -s "$ZSH_PATH" "$USER"
log_success "Default shell changed to zsh"
log_info "Note: You need to log out and back in for shell change to take effect"
else
log_detail "zsh is already the default shell"
fi
# Install Oh My Zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then
log_info "Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
log_success "Oh My Zsh installed"
else
log_detail "Oh My Zsh already installed"
fi
# Install zsh plugins
log_info "Installing zsh plugins..."
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
if [ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
log_success "zsh-autosuggestions installed"
else
log_detail "zsh-autosuggestions already installed"
fi
if [ ! -d "$ZSH_CUSTOM/plugins/fast-syntax-highlighting" ]; then
git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git \
"$ZSH_CUSTOM/plugins/fast-syntax-highlighting"
log_success "fast-syntax-highlighting installed"
else
log_detail "fast-syntax-highlighting already installed"
fi
log_info "Setting up .zshrc..."
if [ -f "$HOME/.zshrc" ] || [ -L "$HOME/.zshrc" ]; then
if [ -e "$HOME/.zshrc" ]; then
backup_file "$HOME/.zshrc" || {
log_error "Failed to backup .zshrc"
exit 1
}
fi
remove_path "$HOME/.zshrc"
fi
cp "$DOTFILES_DIR/default/.zshrc" "$HOME/.zshrc"
log_success "Zsh setup finished"