-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotfiles.sh
executable file
·94 lines (77 loc) · 2.42 KB
/
dotfiles.sh
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
#!/bin/bash
# Created: 03-May-2015 (Bob Heckel)
# Modified: 05-Mar-2023 (Bob Heckel)
# No leading dots!
#if [ -z WSL_DISTRO_NAME ]; then
# majordots='bashrc vimrc tmux.conf inputrc minttyrc gitconfig'
#else
majordots='bashrc vimrc tmux.conf inputrc minttyrc gitconfig'
#fi
myhome=$HOME
# Debug toggle
#myhome=$(pwd)
if [ "$#" -ge 1 ]; then
cat <<EOT
Usage: $0
Setup dotfiles ($majordots) in a new environment
Assumes $HOME/dotfiles/ is where we cloned
Alternatively for specific dotfiles only e.g.:
$ echo 'source ~/dotfiles/_vimrc' >> ~/.vimrc && echo 'source ~/dotfiles/_bashrc' >> ~/.bashrc
EOT
exit 1
fi
function strlen {
echo ${#1}
}
cd $myhome
echo
echo -n "Setup dotfiles in $myhome? "
read
#maxlen=0
#for f in $majordots; do
# len=$(strlen "$myhome/.$f")
# if (( len > maxlen )); then
# maxlen=$len
# fi
#done
for f in $majordots; do
echo -n "setting up "
# len=$(strlen "$myhome/.$f")
# padding=$((maxlen-len))
# printf "%s%*s" "$myhome/.$f " $padding ""
if [ -e $myhome/.$f ] || [ -L $myhome/.$f ]; then
mv $myhome/.$f $myhome/.$f.ORIG
fi
#TODO
#export fg_green="[0;32m"
line='.........................'
#ln -s $myhome/dotfiles/_$f $myhome/.$f && echo "[[0;32m OK [0m]"
ln -s $myhome/dotfiles/_$f $myhome/.$f && printf "%s %s [[0;32m OK [0m]\n" $f "${line:${#f}}"
done
# 24-Aug-19 works on Oracle VM so commenting out
# These won't source as a symlink:
# for f in inputrc; do
# echo setting up $myhome/.$f...
# if [ -e $myhome/.$f ] || [ -L $myhome/.$f ]; then
# mv -i $myhome/.$f $myhome/.$f.ORIG
# echo .$f was backed-up as .$f.ORIG
# else
# echo .$f does not yet exist
# fi
# cp $myhome/dotfiles/_$f $myhome/.$f
# done
# For vim swapfile
if [ ! -e $HOME/tmp ]; then
mkdir $HOME/tmp
fi
if [ -e /cygdrive ]; then
mkdir -p /cygdrive/c/temp && cd ~ && ln -s /cygdrive/c/temp .
fi
#echo
#echo "Consider installing:"
#echo "$ sudo apt-get install tmux vim-nox w3m bc ssh"
#echo "$ sudo dnf install tmux vim-nox w3m bc ssh"
#echo 'or'
#echo "$ sudo apt-get install tmux vim-gtk3 w3m bc ssh"
#echo "$ sudo dnf install tmux vim-gtk3 w3m bc ssh"
#echo