forked from justone/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup
executable file
·119 lines (106 loc) · 5.15 KB
/
setup
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
#!/bin/zsh
# utility functions
function git_clone_or_update() {
if [ -d "$2" ]; then
echo " ====== updating $2"
cd $2 && git pull && cd -
else
echo " ====== cloning $1 into $2"
git clone --depth 1 $1 $2
fi
}
function append_to_file_if_not_present() {
if ! grep -q "$1" $2; then
echo "$1" >> $2
fi
}
# symlink up dotfiles
echo ' ====== installing dotfiles via dfm'
~/dotfiles/bin/dfm install
echo ' ====== installed dotfiles via dfm'
# zsh-specific things
echo ' ====== installing zsh plugins'
mkdir -p ~/.config/zsh
# install zsh plugins
git_clone_or_update https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.config/zsh/zsh-syntax-highlighting
append_to_file_if_not_present "source ~/.config/zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ${ZDOTDIR:-$HOME}/.zshrc
echo ' ====== installed zsh plugins'
# install tmux helpers
echo ' ====== installing tmux plugins'
mkdir -p ~/.config/tmux
git_clone_or_update https://github.com/laktak/extrakto ~/.config/tmux/extrakto
append_to_file_if_not_present "run-shell ~/.config/tmux/extrakto/extrakto.tmux" ~/.tmux.conf
echo ' ====== installed tmux plugins'
# neovim-specific things
echo ' ====== installing neovim plugins'
mkdir -p ~/.local/share/nvim/site/pack/git-plugins/start
# install neovim plugins
git_clone_or_update https://github.com/dense-analysis/ale.git ~/.local/share/nvim/site/pack/git-plugins/start/ale
git_clone_or_update https://github.com/tpope/vim-fugitive.git ~/.local/share/nvim/site/pack/git-plugins/start/vim-fugitive
git_clone_or_update https://github.com/tpope/vim-surround.git ~/.local/share/nvim/site/pack/git-plugins/start/vim-surround
git_clone_or_update https://github.com/tpope/vim-repeat.git ~/.local/share/nvim/site/pack/git-plugins/start/vim-repeat
git_clone_or_update https://github.com/airblade/vim-gitgutter.git ~/.local/share/nvim/site/pack/git-plugins/start/vim-gitgutter
git_clone_or_update https://github.com/ruanyl/vim-gh-line.git ~/.local/share/nvim/site/pack/git-plugins/start/vim-gh-line
git_clone_or_update https://github.com/kana/vim-textobj-user.git ~/.local/share/nvim/site/pack/git-plugins/start/vim-textobj-user
git_clone_or_update https://github.com/tek/vim-textobj-ruby.git ~/.local/share/nvim/site/pack/git-plugins/start/vim-textobj-ruby
git_clone_or_update https://github.com/jiangmiao/auto-pairs.git ~/.local/share/nvim/site/pack/git-plugins/start/auto-pairs
git_clone_or_update https://github.com/github/copilot.vim.git ~/.local/share/nvim/site/pack/git-plugins/start/copilot.vim
git_clone_or_update https://github.com/maxmx03/solarized.nvim.git ~/.local/share/nvim/site/pack/git-plugins/start/solarized.nvim
git_clone_or_update https://github.com/junegunn/fzf.vim.git ~/.local/share/nvim/site/pack/git-plugins/start/fzf.vim
# git_clone_or_update https://github.com/thiagoalessio/rainbow_levels.vim.git ~/.local/share/nvim/site/pack/git-plugins/start/rainbow_levels.vim
# git_clone_or_update https://github.com/folke/zen-mode.nvim.git ~/.local/share/nvim/site/pack/git-plugins/start/zen-mode.nvim
echo ' ====== installed neovim plugins'
__setup_ubuntu(){
if [ "$(dpkg --print-architecture)" = "amd64" ]; then
echo "Ubuntu detected"
sudo apt-get install -y ripgrep fzf exuberant-ctags xsel bat
append_to_file_if_not_present "source /usr/share/doc/fzf/examples/fzf.vim" ~/.vimrc
append_to_file_if_not_present "source /usr/share/doc/fzf/examples/fzf.vim" ~/.config/nvim/init.vim
else
echo "Ubuntu detected, but not amd64"
__setup_unsupported
fi
if command -v nix-env &> /dev/null
then
echo "Nix detected"
nix-env -iA nixpkgs.bash nixpkgs.git nixpkgs.ripgrep nixpkgs.fzf nixpkgs.ctags nixpkgs.bat
fi
}
__setup_linux(){
echo "Detected Linux!"
echo "Checking distro..."
if (uname -a | grep -qi "Microsoft"); then
OS="ubuntuwsl"
elif ! command -v lsb_release &> /dev/null; then
echo "lsb_release could not be found. Falling back to /etc/os-release"
OS="$(grep -Po '(?<=^ID=).*$' /etc/os-release | tr '[:upper:]' '[:lower:]')" 2>/dev/null
else
OS=$(lsb_release -i | awk '{ print $3 }' | tr '[:upper:]' '[:lower:]')
fi
case "$OS" in
"ubuntu" | "ubuntuwsl" | "debian" | "linuxmint" | "parrot" | "kali" | "elementary" | "pop")
__setup_ubuntu;;
*)
__setup_unsupported;;
esac
}
__setup_mac(){
echo "Detected Mac!"
if command -v brew &> /dev/null
then
echo "Refreshing your brew"
brew update && brew upgrade && brew cleanup
echo "Installing basics with brew bundle"
brew bundle install --no-lock --file ~/Brewfile
else
echo "Could not find brew"
fi
}
__setup_unsupported(){
echo " ====== Unknown or unsupported OS or architecture"
}
case "$OSTYPE" in
linux*) __setup_linux ;;
darwin*) __setup_mac ;;
*) __setup_unsupported ;;
esac