-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·156 lines (141 loc) · 4.14 KB
/
setup.sh
File metadata and controls
executable file
·156 lines (141 loc) · 4.14 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env bash
set -xe
function deployDotfiles() {
DOT_FILES=( .tigrc .ideavimrc .agignore .zshrc .zshrc.selector \
.zshrc.alias .zshrc.linux .zshrc.osx .zshenv \
.gitconfig .gitignore \
.tmux.conf .perltidyrc .mackup.cfg \
.zprofile .direnvrc
)
DOT_DIRS=(.zsh .vim .selector )
# dotfiles
for file in "${DOT_FILES[@]}"
do
if [[ ! -e $HOME/$file ]] && [[ ! -L $HOME/$file ]]; then
ln -s "$HOME/dotfiles/$file" "$HOME/$file"
fi
done
# dotdirs
for directory in "${DOT_DIRS[@]}"
do
if [[ ! -d $HOME/${directory}/ ]]; then
ln -s "$HOME/dotfiles/${directory}" "$HOME/${directory}"
fi
done
# TODO : ^-- SC2086 (info): Double quote to prevent globbing and word splitting.
NVIM_CONFIG_DIR="$HOME/.config/nvim"
if [[ ! -d "$NVIM_CONFIG_DIR" ]]; then
mkdir -p "$NVIM_CONFIG_DIR"
fi
if [[ ! -L "$NVIM_CONFIG_DIR/init.lua" ]]; then
ln -s "$HOME/dotfiles/init.lua" "$NVIM_CONFIG_DIR/init.lua"
fi
if [[ ! -L "$NVIM_CONFIG_DIR/lua" ]]; then
ln -s "$HOME/dotfiles/lua" "$NVIM_CONFIG_DIR/lua"
fi
if [[ ! -L "$NVIM_CONFIG_DIR/ginit.vim" ]]; then
ln -s "$HOME/dotfiles/ginit.vim" "$NVIM_CONFIG_DIR/ginit.vim"
fi
}
function changeShell() {
if [[ ! "$SHELL" =~ .+zsh$ ]]; then
if [[ -z $CIRCLECI ]]; then
if [[ ${OSTYPE} =~ "^darwin" ]]; then
sudo which zsh |sudo tee -a /private/etc/shells
fi
chsh -s "$(command -v zsh)"
fi
fi
}
function deployLocalBin() {
if [[ ! -d $HOME/local/bin ]]; then
mkdir -p "$HOME/local/bin/"
ln -s "$HOME/dotfiles/bin/git_diff_wrapper" "$HOME/local/bin/git_diff_wrapper"
ln -s "$HOME/dotfiles/bin/php-xdebug" "$HOME/local/bin/php-xdebug"
fi
}
function deploySnippets() {
local target_dir
target_dir="$(readlink "$HOME/.vim")/snippets"
if [[ ! -e "$target_dir" ]]; then
mkdir -p "$target_dir"
git clone https://github.com/umiyosh/snippets.git "$target_dir"
fi
}
function installZgen() {
## zgen
local target_dir
target_dir="$(readlink "$HOME/.zsh")/extention/zgen"
if [[ ! -d "$target_dir" ]]; then
mkdir -p "$target_dir"
git clone https://github.com/tarjoilija/zgen.git "$target_dir"
fi
}
function installFzf() {
if ! hash fzf; then
case "${OSTYPE}" in
darwin*)
brew install fzf
;;
linux*)
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install --no-key-bindings --no-completion --no-update-rc
;;
esac
fi
}
function setupNeovimPlugins() {
# Neovim with Lazy.nvim
# Lazy.nvimのブートストラップとプラグインインストール
if command -v nvim >/dev/null 2>&1; then
echo "Installing Neovim plugins with Lazy.nvim..."
nvim --headless "+Lazy! sync" +qa
else
echo "Neovim not found, skipping plugin installation"
fi
}
function setupGhAliases() {
if command -v gh >/dev/null 2>&1; then
echo "Setting up GitHub CLI aliases..."
gh alias set --clobber --shell openpr \
'gh api "repos/{owner}/{repo}/commits/$1/pulls" --jq ".[0].number" | xargs -r gh pr view --web'
fi
}
function deployTmuxPowerline() {
# Ensure XDG config dir exists
local TP_SRC_DIR="$HOME/dotfiles/.config/tmux-powerline"
local TP_DEST_DIR="$HOME/.config/tmux-powerline"
if [[ ! -d "$HOME/.config" ]]; then
mkdir -p "$HOME/.config"
fi
# Link config directory
if [[ -L "$TP_DEST_DIR" ]]; then
# If it's a symlink but points elsewhere, replace it
local current_target
current_target="$(readlink "$TP_DEST_DIR")"
if [[ "$current_target" != "$TP_SRC_DIR" ]]; then
rm -f "$TP_DEST_DIR"
ln -s "$TP_SRC_DIR" "$TP_DEST_DIR"
fi
elif [[ -d "$TP_DEST_DIR" ]]; then
# Backup existing dir then link
local backup_dir
backup_dir="${TP_DEST_DIR}.bak-$(date +%Y%m%d%H%M%S)"
mv "$TP_DEST_DIR" "$backup_dir"
ln -s "$TP_SRC_DIR" "$TP_DEST_DIR"
echo "Backed up existing $TP_DEST_DIR to $backup_dir and created symlink."
else
ln -s "$TP_SRC_DIR" "$TP_DEST_DIR"
fi
}
: "install" && {
deployDotfiles
changeShell
deployLocalBin
deploySnippets
installZgen
installFzf
setupNeovimPlugins
deployTmuxPowerline
setupGhAliases
}