-
Notifications
You must be signed in to change notification settings - Fork 0
/
installconfig.sh
137 lines (126 loc) · 6.59 KB
/
installconfig.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
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
#!/bin/bash
# git config
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global color.ui auto
git config --global core.editor vim
# 윈도우에서만 autocrlf 활성화 하자, 기본은 false
git config --global core.autocrlf false
git config --global merge.tool vimdiff
# user_email="[email protected]"
# user_name="ysoftman"
# 이미 사용자 정보가 설정되어 있으면 덮어쓰기때문에 확인하고 사용하자
echo -e "(current) git config --global user.email: $(git config --global user.email)"
echo -ne "(new) git config --global user.email: (empty to keep current user email)"
read -r answer
if [[ ${answer} != '' ]]; then
user_email=${answer}
echo "user.email:" ${user_email}
git config --global user.email ${user_email}
fi
echo -e "(current) git config --global user.name: $(git config --global user.name)"
echo -ne "(new) git config --global user.name: (empty to keep current user name)"
read -r answer
if [[ ${answer} != '' ]]; then
user_name=${answer}
echo "user.name:" ${user_name}
git config --global user.name ${user_name}
fi
if delta --version 2> /dev/null 2>&1; then
echo "set delta to git global config"
git config --global core.pager "delta"
git config --global interactive.diffFilter "delta --color-only"
git config --global add.interactive.userBuiltin "false"
git config --global delta.navigate "true"
git config --global delta.light "false"
git config --global delta.line-numbers "true"
git config --global delta.side-by-side "true"
git config --global delta.syntax-theme "OneHalfDark"
fi
if difft --version 2> /dev/null 2>&1; then
# `git log` with patches shown with difftastic.
git config --global alias.dl '-c diff.external=difft log -p --ext-diff'
# Show the most recent commit with difftastic.
git config --global alias.ds '-c diff.external=difft show --ext-diff'
# `git diff` with difftastic.
git config --global alias.dft '-c diff.external=difft diff'
fi
# 파일로 저장하지 않고 일정시간(디폴트 15분)동안 id,pw 를 캐싱한다.
#git config --global credential.helper cache
# save credential(password)
git config --global credential.helper store
# gitignore, bash, zsh, vim, tmux, tigrc, mutt 등 기본 설정
export XDG_CONFIG_HOME="$HOME/.config"
[ -h ~/.gitignore_global ] && unlink ~/.gitignore_global
[ -h ~/.bashrc ] && unlink ~/.bashrc
[ -h ~/.zshrc ] && unlink ~/.zshrc
[ -h ~/.vimrc ] && unlink ~/.vimrc
[ -h ${XDG_CONFIG_HOME}/nvim ] && unlink ${XDG_CONFIG_HOME}/nvim
[ -h ~/.tmux.conf ] && unlink ~/.tmux.conf
[ -h ~/.shellcheckrc ] && unlink ~/.shellcheckrc
[ -h ~/.tigrc ] && unlink ~/.tigrc
[ -h ~/.muttrc ] && unlink ~/.muttrc
[ -d ${XDG_CONFIG_HOME}/alacritty-colorscheme ] || git clone https://github.com/alacritty/alacritty-theme ${XDG_CONFIG_HOME}/alacritty-colorscheme
[ -h ${XDG_CONFIG_HOME}/alacritty ] && unlink ${XDG_CONFIG_HOME}/alacritty
[ -h ${XDG_CONFIG_HOME}/cava ] && unlink ${XDG_CONFIG_HOME}/cava
[ -h ${XDG_CONFIG_HOME}/harlequin ] && unlink ${XDG_CONFIG_HOME}/harlequin
[ -h ${XDG_CONFIG_HOME}/k9s ] && unlink ${XDG_CONFIG_HOME}/k9s
[ -h ${XDG_CONFIG_HOME}/karabiner ] && unlink ${XDG_CONFIG_HOME}/karabiner
[ -h ${XDG_CONFIG_HOME}/kitty ] && unlink ${XDG_CONFIG_HOME}/kitty
[ -h ${XDG_CONFIG_HOME}/lsd ] && unlink ${XDG_CONFIG_HOME}/lsd
[ -h ${XDG_CONFIG_HOME}/mc ] && unlink ${XDG_CONFIG_HOME}/mc
[ -h ${XDG_CONFIG_HOME}/zellij ] && unlink ${XDG_CONFIG_HOME}/zellij
# backup previous settings
[ -f ~/.gitignore_global ] && mv -fv ~/.gitignore_global ~/.gitignore_global.bak
[ -f ~/.bashrc ] && mv -fv ~/.bashrc ~/.bashrc.bak
[ -f ~/.zshrc ] && mv -fv ~/.zshrc ~/.zshrc.bak
[ -f ~/.vimrc ] && mv -fv ~/.vimrc ~/.vimrc.bak
[ -f ${XDG_CONFIG_HOME}/nvim/init.vim ] && mv -fv ${XDG_CONFIG_HOME}/nvim ${XDG_CONFIG_HOME}/nvim.bak
[ -f ~/.tmux.conf ] && mv -fv ~/.tmux.conf ~/.tmux.conf.bak
[ -f ~/.shellcheckrc ] && mv -fv ~/.shellcheckrc ~/.shellcheckrc.bak
[ -f ~/.tigrc ] && mv -fv ~/.tigrc ~/.tigrc.bak
[ -f ~/.muttrc ] && mv -fv ~/.muttrc ~/.muttrc.bak
[ -d ${XDG_CONFIG_HOME}/alacritty ] && mv -fv ${XDG_CONFIG_HOME}/alacritty ${XDG_CONFIG_HOME}/alacritty.bak
[ -d ${XDG_CONFIG_HOME}/cava ] && mv -fv ${XDG_CONFIG_HOME}/cava ${XDG_CONFIG_HOME}/cava.bak
[ -d ${XDG_CONFIG_HOME}/harlequin ] && mv -fv ${XDG_CONFIG_HOME}/harlequin ${XDG_CONFIG_HOME}/harlequin.bak
[ -d ${XDG_CONFIG_HOME}/k9s ] && mv -fv ${XDG_CONFIG_HOME}/k9s ${XDG_CONFIG_HOME}/k9s.bak
[ -d ${XDG_CONFIG_HOME}/karabiner ] && mv -fv ${XDG_CONFIG_HOME}/karabiner ${XDG_CONFIG_HOME}/karabiner.bak
[ -d ${XDG_CONFIG_HOME}/kitty ] && mv -fv ${XDG_CONFIG_HOME}/kitty ${XDG_CONFIG_HOME}/kitty.bak
[ -d ${XDG_CONFIG_HOME}/lsd ] && mv -fv ${XDG_CONFIG_HOME}/lsd ${XDG_CONFIG_HOME}/lsd.bak
[ -d ${XDG_CONFIG_HOME}/mc ] && mv -fv ${XDG_CONFIG_HOME}/mc ${XDG_CONFIG_HOME}/mc.bak
[ -d ${XDG_CONFIG_HOME}/zellij ] && mv -fv ${XDG_CONFIG_HOME}/zellij ${XDG_CONFIG_HOME}/zellij.bak
# ubuntu 에서는 이름이 달라서 link 처리한다.
[ -f /usr/bin/fdfind ] && sudo ln -sf /usr/bin/fdfind /usr/bin/fd
[ -f /usr/bin/batcat ] && sudo ln -sf /usr/bin/batcat /usr/bin/bat
ln -sf ${PWD}/.gitignore_global ~/.gitignore_global
ln -sf ${PWD}/.bashrc ~/.bashrc
ln -sf ${PWD}/.zshrc ~/.zshrc
ln -sf ${PWD}/.vimrc ~/.vimrc
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/nvim ${XDG_CONFIG_HOME}/nvim
ln -sf ${PWD}/.tmux.conf ~/.tmux.conf
ln -sf ${PWD}/.shellcheckrc ~/.shellcheckrc
ln -sf ${PWD}/.tigrc ~/.tigrc
ln -sf ${PWD}/.muttrc ~/.muttrc
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/alacritty ${XDG_CONFIG_HOME}/alacritty
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/cava ${XDG_CONFIG_HOME}/cava
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/harlequin ${XDG_CONFIG_HOME}/harlequin
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/karabiner ${XDG_CONFIG_HOME}/karabiner
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/k9s ${XDG_CONFIG_HOME}/k9s
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/kitty ${XDG_CONFIG_HOME}/kitty
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/lsd ${XDG_CONFIG_HOME}/lsd
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/mc ${XDG_CONFIG_HOME}/mc
[ -d ${XDG_CONFIG_HOME} ] && ln -sf ${PWD}/zellij ${XDG_CONFIG_HOME}/zellij
# wsl 환경인 경우 wsl.conf 설정
if [[ $(uname -a) == *"microsoft"* ]]; then
# link 적용 안됨
# sudo ln -sf ${PWD}/wsl.conf /etc/wsl.conf
sudo unlink /etc/wsl.conf 2> /dev/null
sudo cp -fv ${PWD}/wsl.conf /etc/wsl.conf
echo "윈도우 실행에서 wsl -t ubuntu 로 종료 후 터미널 다시 시작 필요"
fi
# 보안사항으로 커밋하면 안됨.
# cp -fv ./.ssh/* ~/.ssh
# 보안사항으로 커밋하면 안됨.
#sudo cp -fv hosts /etc/hosts