-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·60 lines (50 loc) · 1.59 KB
/
setup
File metadata and controls
executable file
·60 lines (50 loc) · 1.59 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
#!/bin/bash
############################
# This script creates symlinks from the home directory to any desired dotfiles
# in ~/dotfiles
############################
dir=~/dotfiles # dotfiles directory
olddir=~/dotfiles_old # old dotfiles backup directory
dotfile_dirs="shell git editor terminal" # directories containing dotfiles to link to $HOME
home_bin=$HOME/bin # directory for executables stored in this repository
nvim_parent_dir=$HOME/.config # directory for neovim configurations
while getopts "x" option; do
case ${option} in
x)
script_only=1
;;
\?) #For invalid option
echo "Invalid argument provided"
exit 1
;;
esac
done
# change to the dotfiles directory
cd $dir
# only execute if the $script_only variable is not set
if [ -z "${script_only+x}" ]; then
# move any existing dotfiles in homedir to dotfiles_old directory, then create symlinks
# create dotfiles_old in homedir
mkdir -p $olddir
for dotfile_dir in $dotfile_dirs; do
for file in $dir/$dotfile_dir/*; do
if [ -f "$file" ]; then
basename=$(basename "$file")
mv $HOME/.$basename $olddir
ln -s $file $HOME/.$basename
fi
done
done
# symlink nvim configurations
ln -s -f $dir/editor/nvim $nvim_parent_dir
echo "Moved all existing dotfiles to $olddir."
fi
# Move files in scripts folder to /bin in $HOME
mkdir -p $home_bin
for file in $dir/scripts/*; do
if [ -f "$file" ]; then
scriptname=$(basename "$file")
ln -s -f $file $home_bin/$scriptname
fi
done
echo "Complete"