-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·139 lines (107 loc) · 3.33 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
set -e
function config() {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
function aptInstall {
local app=$1
if [[ -z "$app" ]]; then
echo "Invalid argument missing component name"
return 1
fi
local appInstalled=$(dpkg -l | grep -iq "^ii\s*$app" && echo "installed")
# Guard clause to not install more than once
if [[ -n $appInstalled ]]; then
echo "$app is installed by apt-get"
return 0;
fi
echo "apt-get Installing: $app"
sudo apt-get update
sudo apt-get install "$app" -y
}
function cargoInstall {
local app=$1
local echoBootstrap=$2
if [[ -z "$app" ]]; then
echo "Missing required argument: the name of the cargo package to install"
return 1
fi
local installed=$(cargo install --list | grep -iq "$app" && echo "installed")
# Guard clause to not install more than once
if [[ -n $installed ]]; then
echo "$app is installed by cargo"
return 0;
fi
echo "Cargo Installing: $app"
cargo install "$app" --locked
}
function createAlias() {
local aliasName=$1
local aliasValue=$2
local aliasExists=$(grep "alias $aliasName=\"$aliasValue\"" "$HOME/.zshrc")
[[ -n $aliasExists ]] || echo "alias $aliasName=\"$aliasValue\"" >> $HOME/.zshrc
}
# Setup Config files for managing dotfiles
config config --local status.showUntrackedFiles no
createAlias "config" "/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME"
if [ "$#" -ne 2 ]; then
echo "Please call this script with the desired git user.name and user.email:"
echo "./setup \"username\" \"user.email\""
exit 1
fi
[[ "$1" == $(config config user.name) ]] || config config user.name "$1"
[[ "$2" == $(config config user.email) ]] || config config user.email "$2"
# Install Oh-My-Zsh
if [ ! -d ~/.oh-my-zsh ]; then
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
echo "Restart the script to complete the setup"
source $HOME/.zshrc
fi
# Install Autosuggestions for Oh-My-Zsh
if [ ! -d ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ]; then
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
sed -i 's/^plugins=(\(.*\))/plugins=(\1 zsh-autosuggestions)/' $HOME/.zshrc
fi
aptInstall build-essential
if ! which -s rustup; then
echo "Installing Rust via Rustup"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
fi
aptInstall unzip
aptInstall xclip
cargoInstall "bob-nvim"
if ! which -s nvim; then
echo "Installing NeoVim Stable"
bob install stable
bob use stable
echo 'export PATH=$PATH:$HOME/.local/share/bob/nvim-bin' >> $HOME/.zshrc
source $HOME/.zshrc
fi
aptInstall cmake
if ! which -s starship; then
echo "Installing Starship Prompt 🚀"
cargo install starship --locked
echo 'eval "$(starship init zsh)"' >> $HOME/.zshrc
fi
cargoInstall "bat"
createAlias "cat" "bat"
cargoInstall "ripgrep"
cargoInstall "eza"
createAlias "ls" "eza"
createAlias "ll" "eza -lh"
cargoInstall "tealdeer"
aptInstall libasound2-dev
aptInstall librust-alsa-sys-dev
cargoInstall "porsmo"
#if ! which -s gitui; then
# echo "Installing GitUI"
# cargo install gitui
#fi
aptInstall libssl-dev
if ! which -s mise; then
echo "Installing mise"
cargo install mise
echo 'eval "$(mise activate zsh)"' >> "${ZDOTDIR-$HOME}/.zshrc"
fi
createAlias "c" "clear"