This repository was archived by the owner on Apr 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcp-dotfiles.sh
More file actions
executable file
·103 lines (83 loc) · 2.5 KB
/
Copy pathcp-dotfiles.sh
File metadata and controls
executable file
·103 lines (83 loc) · 2.5 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
#!/bin/bash
# Get the directory regardless of where its called
ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
# Get Array ( ) of the LS Grep
DOTFILES=( $(ls -a $ROOTDIR | egrep "^\.[a-zA-Z]") )
# Simple Colors
NOCOLOR='\033[0m'
YELLOW='\033[01;33m'
# Empty Array to separate files/folders
FILES=()
DIRS=()
for item in "${DOTFILES[@]}"; do
[[ -f "./${item}" ]] && FILES+=($ROOTDIR/$item) && continue
# Ignore the .git folder, that'll be bad!
[[ -d "./${item}" && "${item}" != ".git" ]] && DIRS+=($ROOTDIR/$item)
done
copyfiles() {
echo -e "Copying Files.."
for file in "${FILES[@]}"; do
echo "[+] Copy: ${file} to ${HOME}"
cp $file $HOME
done
}
copydirs() {
echo -e "Copying Directories.."
for dir in "${DIRS[@]}"; do
echo "[+] Copy: ${dir} to ${HOME}"
cp -r $dir $HOME
done
# Copy the config files into ~/.config $XDG_CONFIG_HOME
cp -R config/* ~/.config
cp -R local/* ~/.local
echo "[+] Copy: config/* to ~/.config/"
echo "[+] Copy: local/* to ~/.local/"
}
for d in "${DIRS[@]}"; do
printf "%-8s\n" "${d}"
done | printf "%-8s\n" "config" | column
# Entry
echo -e "\n ${YELLOW}-------------------------------------------${NOCOLOR}"
echo -e " ${YELLOW}Copy Dotfiles to Home Folder${NOCOLOR}"
echo -e " ${YELLOW}-------------------------------------------${NOCOLOR}"
# 8 column max array
echo -e "${YELLOW}[ Files ]${NOCOLOR}"
for f in "${FILES[@]}"; do
printf "%-8s\n" "${f}"
done | column
echo -e "\n${YELLOW}[ Directories ]${NOCOLOR}"
for d in "${DIRS[@]}"; do
printf "%-8s\n" "${d}"
done | column
echo "Also: config/ will populate ~/.config/"
echo -e "\n ${YELLOW}------------------------------------------- ${NOCOLOR}\n"
# User Prompt
echo -e "(1/2) Copy the above ${YELLOW}FILES${NOCOLOR} to ${HOME} folder ${YELLOW}[y/N]${NOCOLOR}?:"
read -p "(1/2) Copy to $HOME?: " ynFiles
echo -e "(2/2) Copy the above ${YELLOW}DIRECTORIES${NOCOLOR} to ${HOME} folder ${YELLOW}[y/N]${NOCOLOR}?"
read -p "(2/2) Copy to $HOME?: " ynDirs
# Flag for output at the end
DID_RUN=0
# Copy Files
if [[ $ynFiles =~ ^([yY])+$ ]]; then
copyfiles
DID_RUN=1
fi
# Copy Dirs
if [[ $ynDirs =~ ^([yY])+$ ]]; then
copydirs
DID_RUN=1;
# Vundle
if [ -d ~/.config/vim ]; then
git clone https://github.com/VundleVim/Vundle.vim.git ~/.config/vim/bundle/Vundle.vim
vim +PluginInstall +qall
fi
fi
# Final Result
if [[ $DID_RUN == 1 ]]; then
echo -e "\n[+] Finished, make sure to run:"
echo -e " $ source ~/.bashrc"
exit 1
fi
echo -e "\nExiting...\n"
exit 1