-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·131 lines (112 loc) · 4.62 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·131 lines (112 loc) · 4.62 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# Terminal Configuration Setup Script
# This script backs up existing configurations and installs new ones
set -e # Exit on error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Get the directory where this script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BACKUP_DIR="$HOME/.config-backup-$(date +%Y%m%d-%H%M%S)"
echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Terminal Configuration Setup ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════╝${NC}"
echo ""
# Function to backup a file or directory
backup_if_exists() {
local source="$1"
local name="$2"
if [ -e "$source" ]; then
echo -e "${YELLOW}→${NC} Backing up existing $name..."
mkdir -p "$BACKUP_DIR"
cp -r "$source" "$BACKUP_DIR/"
echo -e "${GREEN}✓${NC} Backed up to: $BACKUP_DIR/$(basename "$source")"
return 0
fi
return 1
}
# Function to install a config file
install_config() {
local source="$1"
local target="$2"
local name="$3"
if [ -f "$source" ]; then
echo -e "${YELLOW}→${NC} Installing $name..."
cp "$source" "$target"
echo -e "${GREEN}✓${NC} Installed $name"
return 0
else
echo -e "${RED}✗${NC} $name not found in repo"
return 1
fi
}
# Function to install a config directory
install_config_dir() {
local source="$1"
local target="$2"
local name="$3"
if [ -d "$source" ]; then
echo -e "${YELLOW}→${NC} Installing $name..."
mkdir -p "$(dirname "$target")"
cp -r "$source" "$target"
echo -e "${GREEN}✓${NC} Installed $name"
return 0
else
echo -e "${RED}✗${NC} $name directory not found in repo"
return 1
fi
}
echo -e "${BLUE}Step 1: Backing up existing configurations${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
backup_if_exists "$HOME/.zshrc" "zshrc"
backup_if_exists "$HOME/.zprofile" "zprofile"
backup_if_exists "$HOME/.bashrc" "bashrc"
backup_if_exists "$HOME/.bash_profile" "bash_profile"
backup_if_exists "$HOME/.gitconfig" "gitconfig"
backup_if_exists "$HOME/.tmux.conf" "tmux.conf"
backup_if_exists "$HOME/.config/nvim" "neovim config"
if [ -d "$BACKUP_DIR" ]; then
echo -e "${GREEN}✓${NC} All existing configs backed up to: ${BACKUP_DIR}"
else
echo -e "${BLUE}ℹ${NC} No existing configs to backup"
fi
echo ""
echo -e "${BLUE}Step 2: Installing new configurations${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
# Install shell configs
install_config "$SCRIPT_DIR/.zshrc" "$HOME/.zshrc" "zsh config"
install_config "$SCRIPT_DIR/.zprofile" "$HOME/.zprofile" "zsh profile"
install_config "$SCRIPT_DIR/.bashrc" "$HOME/.bashrc" "bash config"
install_config "$SCRIPT_DIR/.bash_profile" "$HOME/.bash_profile" "bash profile"
# Install development tool configs
install_config "$SCRIPT_DIR/.gitconfig" "$HOME/.gitconfig" "git config"
install_config "$SCRIPT_DIR/.tmux.conf" "$HOME/.tmux.conf" "tmux config"
# Install neovim config
install_config_dir "$SCRIPT_DIR/nvim" "$HOME/.config/nvim" "neovim config"
echo ""
echo -e "${GREEN}╔════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Installation Complete! 🎉 ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════╝${NC}"
echo ""
echo -e "${BLUE}Next Steps:${NC}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "1. ${YELLOW}Reload your shell:${NC}"
echo -e " source ~/.zshrc ${BLUE}# for zsh${NC}"
echo -e " source ~/.bashrc ${BLUE}# for bash${NC}"
echo ""
echo -e "2. ${YELLOW}Update Git config with your info:${NC}"
echo -e " git config --global user.name \"Your Name\""
echo -e " git config --global user.email \"your.email@example.com\""
echo ""
echo -e "3. ${YELLOW}Open Neovim to install plugins:${NC}"
echo -e " nvim"
echo ""
if [ -d "$BACKUP_DIR" ]; then
echo -e "${BLUE}ℹ${NC} Your old configs are backed up at:"
echo -e " ${BACKUP_DIR}"
echo ""
fi
echo -e "${GREEN}Happy coding!${NC}"