-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·108 lines (97 loc) · 4.37 KB
/
install.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
#!/bin/bash
# some helper functions, credits to Ben "cowboy" Alman
# see https://github.com/cowboy/dotfiles/blob/master/bin/dotfiles#L26-L30
function e_header() { echo -e "\n\033[1m$*\033[0m"; }
function e_success() { echo -e " \033[1;32m✔\033[0m $*"; }
function e_error() { echo -e " \033[1;31m✖\033[0m $*"; }
function e_arrow() { echo -e " \033[1;34m➜\033[0m $*"; }
function symlink() {
local dir_to_create
dir_to_create=$(dirname "${2}")
if [ ! -d "$dir_to_create" ]; then
e_error "directory $dir_to_create does not exist, let's create it"
mkdir -p "$dir_to_create"
fi
if [ -h "$2" ]; then
local target
target=$(readlink -f "${2}")
if [ "$1" == "$target" ]; then
# don't create symlink if it exists and the target is the same
return 0
fi
fi
if [ -f "$2" ]; then
e_error "File ($2) already exists!"
local newname
newname=$2.$(date +%s)
mv "$2" "$newname" && e_success "renamed to $newname"
fi
ln -s "$1" "$2"
}
# zsh
if [ ! -d "$HOME/.oh-my-zsh" ]; then
e_error "oh-my-zsh not found!"
e_header "install it automatically..."
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$HOME/.oh-my-zsh"
if [ -d "$HOME/.oh-my-zsh" ]; then
e_success "installed oh-my-zsh"
fi
fi
if [ -d "$HOME/.oh-my-zsh" ]; then
symlink "$HOME/.dotfiles/.zshrc" "$HOME/.zshrc"
e_success "created zsh symlinks"
else
e_error "something gone wrong, you need to install oh-my-zsh on manually"
fi
# hyperterm stuff
symlink "$HOME/.dotfiles/.hyper.js" "$HOME/.hyper.js"
e_success "created hyper.js symlinks"
# VIM stuff
symlink "$HOME/.dotfiles/.vim" "$HOME/.vim"
symlink "$HOME/.dotfiles/.vimrc" "$HOME/.vimrc"
symlink "$HOME/.dotfiles/init.vim" "$HOME/.config/nvim/init.vim"
e_success "created vim symlinks"
# sublime-text
SUBLIME_TEXT_USER_PATH=""
SUBLIME_TEXT_DOTFILES_PATH="$HOME/.dotfiles/sublime-text"
if [ "$(uname)" == "Darwin" ]; then
# OS X
SUBLIME_TEXT_USER_PATH="$HOME/Library/Application Support/Sublime Text/Packages/User"
symlink "$SUBLIME_TEXT_DOTFILES_PATH/Default_(OSX).sublime-keymap" "$SUBLIME_TEXT_USER_PATH/Default (OSX).sublime-keymap"
symlink "$SUBLIME_TEXT_DOTFILES_PATH/Default_(OSX).sublime-mousemap" "$SUBLIME_TEXT_USER_PATH/Default (OSX).sublime-mousemap"
e_success "configured sublime text (OSX)"
elif [ "$(uname -s | cut -c 1-5)" == "Linux" ]; then
# Linux
SUBLIME_TEXT_USER_PATH="$HOME/.config/sublime-text-3/Packages/User"
symlink "$SUBLIME_TEXT_DOTFILES_PATH/Default_(Linux).sublime-keymap" "$SUBLIME_TEXT_USER_PATH/Default (Linux).sublime-keymap"
symlink "$SUBLIME_TEXT_DOTFILES_PATH/Default_(Linux).sublime-mousemap" "$SUBLIME_TEXT_USER_PATH/Default (Linux).sublime-mousemap"
e_success "configured sublime text (Linux)"
fi
if [ ! "$SUBLIME_TEXT_USER_PATH" == "" ]; then
symlink "$SUBLIME_TEXT_DOTFILES_PATH/Preferences.sublime-settings" "$SUBLIME_TEXT_USER_PATH/Preferences.sublime-settings"
symlink "$SUBLIME_TEXT_DOTFILES_PATH/phpcs.sublime-settings" "$SUBLIME_TEXT_USER_PATH/phpcs.sublime-settings"
symlink "$SUBLIME_TEXT_DOTFILES_PATH/Snippets" "$SUBLIME_TEXT_USER_PATH/Snippets"
symlink "$SUBLIME_TEXT_DOTFILES_PATH/Package_Control.sublime-settings" "$SUBLIME_TEXT_USER_PATH/Package Control.sublime-settings"
fi
# other
symlink "$HOME/.dotfiles/.ctags" "$HOME/.ctags"
symlink "$HOME/.dotfiles/.ackrc" "$HOME/.ackrc"
symlink "$HOME/.dotfiles/.ripgreprc" "$HOME/.ripgreprc"
symlink "$HOME/.dotfiles/.curlrc" "$HOME/.curlrc"
symlink "$HOME/.dotfiles/.editorconfig" "$HOME/.editorconfig"
symlink "$HOME/.dotfiles/.wgetrc" "$HOME/.wgetrc"
symlink "$HOME/.dotfiles/.colordiffrc" "$HOME/.colordiffrc"
symlink "$HOME/.dotfiles/.tmux" "$HOME/.tmux"
symlink "$HOME/.dotfiles/.tmux.conf" "$HOME/.tmux.conf"
symlink "$HOME/.dotfiles/.tmux-mac" "$HOME/.tmux-mac"
symlink "$HOME/.dotfiles/.tmux-linux" "$HOME/.tmux-linux"
e_success "symlinked other stuff"
# git
symlink "$HOME/.dotfiles/.gitignore_global" "$HOME/.gitignore_global"
symlink "$HOME/.dotfiles/.gitconfig.inc" "$HOME/.gitconfig.inc"
git config --global include.path "$HOME/.gitconfig.inc"
symlink "$HOME/.dotfiles/.gitattributes_global" "$HOME/.gitattributes_global"
e_success "configured git"
e_arrow "reminder: set your git name and email like this: \
\n\t git config --global user.email \"[email protected]\" \
\n\t git config --global user.name \"Foo Bar\""