-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.zsh
executable file
·65 lines (59 loc) · 2.1 KB
/
install.zsh
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
#!/bin/zsh
###############################################################################
# ./install.sh #
# This script creates symlinks from the home directory #
# to any desired dotfiles in ~/dotfiles #
###############################################################################
### Variables
# dotfiles directory
dir="$(dirname "$0")"
# old dotfiles backup directory, dated
backup=$HOME/.dotfiles_$(date "+%Y_%m_%d")
# list of files/folders to symlink in homedir
zsh_files=(zsh_aliases \
zsh_completion \
zsh_config \
zsh_functions \
zsh_keybindings \
zsh_options \
zsh_path \
zsh_prompt \
zshrc)
git_files=(gitconfig \
gitignore_global)
pkg_files=(vimrc \
eslintrc \
curlrc \
tmux.conf)
other_files=(linuxrc \
osxrc)
files=($zsh_files \
$git_files \
$pkg_files \
$other_files)
###############################################################################
# create dotfiles_old in homedir
print "\x1b[32;01m" "Creating $backup for backup of any existing dotfiles in ~"
print $fg[red] "mkdir -p $backup"
mkdir -p $backup
# move any existing dotfiles in dir to backup directory, then create symlinks
for file in $files; do
if [[ -L $HOME/.$file ]]; then
print "\x1b[32;01m .$file is a symlink"
print "\x1b[32;01m removing .$file"
print "\x1b[34;01m rm -f ~/.$file"
rm -f $HOME/.$file
print "\x1b[32;01m ...done"
else
print "\x1b[32;01m .$file is a regular file"
print "\x1b[32;01m moving .$file to $backup/$file"
print "\x1b[34;01m mv ~/.$file $backup/$file"
mv $HOME/.$file $backup/$file
print "\x1b[32;01m ...done"
fi
print "\x1b[32;01m copying .$file to ~/.$file"
print "\x1b[34;01m cp $dir/$file ~/.$file"
cp $dir/$file $HOME/.$file
print "\x1b[32;01m ...done"
done
print "complete"