-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
43 lines (36 loc) · 1.41 KB
/
uninstall.sh
File metadata and controls
43 lines (36 loc) · 1.41 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
#!/bin/bash
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
SCRIPT_NAME="git-commit-shortcuts.zsh"
TARGET_FILE=~/".${SCRIPT_NAME}"
ZSHRC=~/.zshrc
SOURCE_LINE="source ~/.${SCRIPT_NAME}"
# Remove the script file
if [ -f "$TARGET_FILE" ]; then
rm -f "$TARGET_FILE"
echo -e "${GREEN}✓ Removed ${TARGET_FILE}${NC}"
else
echo -e "${YELLOW}ℹ️ ${TARGET_FILE} not found, skipping...${NC}"
fi
# Remove the source line from .zshrc
if [ -f "$ZSHRC" ] && grep -qF "$SOURCE_LINE" "$ZSHRC"; then
# Create a backup of the current .zshrc
cp "$ZSHRC" "${ZSHRC}.bak"
# Remove the source line and any empty lines around it
sed -i '' "/^# Git Commit Shortcuts$/{N;N;d;};" "$ZSHRC" 2>/dev/null || \
sed -i "/^# Git Commit Shortcuts$/{N;N;d;}" "$ZSHRC"
echo -e "${GREEN}✓ Removed git-commit-shortcuts from ${ZSHRC}${NC}"
echo -e "${YELLOW}ℹ️ A backup of your original .zshrc has been saved as ${ZSHRC}.bak${NC}"
else
echo -e "${YELLOW}ℹ️ No git-commit-shortcuts reference found in ${ZSHRC}${NC}"
fi
# Remove the cloned directory if we're running from a cloned repo
if [ -d ~/.git-commit-shortcuts ]; then
rm -rf ~/.git-commit-shortcuts
echo -e "${GREEN}✓ Removed ~/.git-commit-shortcuts directory${NC}"
fi
echo -e "\n${GREEN}✅ Uninstallation complete!${NC}"
echo -e "To apply changes, run: ${YELLOW}source ~/.zshrc${NC} or restart your terminal."
exit 0