-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·89 lines (74 loc) · 2.39 KB
/
setup.sh
File metadata and controls
executable file
·89 lines (74 loc) · 2.39 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
#!/bin/bash
set -x
cd `dirname $0`
########################
## functions
########################
function put_dot_files() {
local dotfiles=(.zshrc .gitconfig .gitignore .vimrc .tmux.conf .ideavimrc .vim/ftplugin .local/bin)
for dotfile in ${dotfiles[@]}; do
[ ! -e ${dotfile} ] && continue # ファイルまたはディレクトリが存在しない場合、スキップ
local destination=${HOME}/${dotfile}
local destination_dir=$(dirname "${destination}")
[ ! -d "${destination_dir}" ] && mkdir -p "${destination_dir}"
if [ -e ${destination} -a ! -L ${destination} ]; then
read -p "File ${dotfile} is already exists. Please choose the action. [b: backup, o: overwrite, q: quit]: " DOTFILE_ACTION
case "${DOTFILE_ACTION}" in
[qQ]) exit 1 ;;
[bB])
local backupfile=${HOME}/${dotfile}.$(date "+%s")
cp -r ${destination} ${backupfile}
echo "Backup file was created! (${backupfile})"
esac
fi
if [ -e "${destination}" ]; then # ファイルまたはディレクトリが存在する場合
rm -r ${destination}
fi
ln -s -f $(pwd)/${dotfile} ${destination}
echo "${dotfile} was created"
done
}
function get_vim_plug_path() {
echo "${HOME}/.vim/autoload/plug.vim"
}
function install_vim_plug() {
local vimplug_inatall_path=$(get_vim_plug_path)
if [ -f ${vimplug_inatall_path} ]; then
echo "vim-plug is already installed."
else
read -p "Are you sure install vim-plug? [y/n]: " INSTALL_VIMPLUG
case "${INSTALL_VIMPLUG}" in
[nN]) exit 1 ;;
esac
curl -sfLo ${vimplug_inatall_path} --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
echo "vim-plug was installed."
fi
}
function install_vim_plugin() {
if [ ! -f "$(get_vim_plug_path)" ]; then
return 0
fi
read -p "Are you sure install Vim plugins by vim-plug? [y/n]: " INSTALL_VIMPLUG_PLUGIN
case "${INSTALL_VIMPLUG_PLUGIN}" in
[nN]) exit 1 ;;
[yY])
vim -c 'let g:plug_window="" | PlugStatus | PlugClean | PlugUpdate | PlugInstall | quit'
echo "Vim plugins was installed."
esac
}
function display_message () {
cat <<EOT
==========================
${1}
==========================
EOT
}
########################
## main
########################
display_message "dotfiles settings"
put_dot_files
display_message "Vim settings"
install_vim_plug
install_vim_plugin