-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·156 lines (133 loc) · 4.62 KB
/
install
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
HOMEBREW_EXISTS="$(command -v brew)"
EZA_EXISTS="$(command -v eza)"
ZSH_EXISTS="$(command -v zsh)"
set -euo pipefail
trap 'log "error" "Script failed at line $LINENO"' ERR
log() {
case $1 in
ERROR | error)
shift
printf "\033[31m[!] ERROR:::\033[0m %b\n" "$@"
;;
INFO | info)
shift
printf "\033[34m[+] INFO:::\033[0m %b\n" "$@"
;;
WARN | warn)
shift
printf "\033[33m[!] WARN:::\033[0m %b\n" "$@"
;;
*)
printf "\033[34m[+] INFO:::\033[0m %b\n" "$@"
;;
esac
}
## git configuration
log info "Configuring git"
git config --global push.autoSetupRemote true
#@--------------------------------@#
# Check if homebrew is installed
#@--------------------------------@#
if test -z "$HOMEBREW_EXISTS"; then
log info "Homebrew not found. Installing.."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || true
fi
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
log info "Installing fzf, bat, tree, jq, mycli, helm, zoxide"
HOMEBREW_NO_AUTO_UPDATE=1 brew install fzf bat tree jq mycli helm zoxide gh eza || true
#@--------------------------------@#
# Configure fzf
# - Install keybindings
# - Install shell completion
# - Do not update shell configuration files
#@--------------------------------@#
log info "Configuring fzf keybindings and shell completion"
"$(brew --prefix)"/opt/fzf/install --key-bindings --completion || true
# Move lnav
log info "Moving lnav"
sudo cp tools/lnav /usr/local/bin/lnav &&
sudo chmod +x /usr/local/bin/lnav
#@--------------------------------@#
# Configuring vim and tmux
#@--------------------------------@#
log info "Installing vim pathogen"
mkdir -p ~/.vim/autoload ~/.vim/bundle &&
curl -LSso ~/.vim/autoload/pathogen.vim https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
log info "Installing apprentice theme"
git clone https://github.com/romainl/Apprentice.git ~/.vim/bundle/apprentice || true
log info "Copying .vimrc"
cp .vimrc ~/.vimrc || true
log info "Copying .tmux.conf"
cp .tmux.conf ~/.tmux.conf || true
#@--------------------------------@#
# Switching to zsh
#@--------------------------------@#
if test -z "$ZSH_EXISTS"; then
log info "zsh not found. Installing.."
HOMEBREW_NO_AUTO_UPDATE=1 brew install zsh
else
log info "zsh already installed. skipping.."
fi
#@---------------------------------@#
# Install omz
#@---------------------------------@#
if test -z "$ZSH_EXISTS"; then
log info "installing omz"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
log info "omz already installed. skipping.."
fi
#@---------------------------------@#
# Install p10k
#@---------------------------------@#
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k || true
cp .p10k.zsh ~/.p10k.zsh
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc
echo '[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh' >>~/.zshrc
#@--------------------------------@#
# Codespaces specific
#@--------------------------------@#
# Search for alias k='kubectl' in the ~/.zshrc and if found, skip
if grep -q "alias k='kubectl'" ~/.zshrc; then
log info "Aliases are pre-configured. skipping.."
else
log info "Updating PATH for zsh"
{
echo "PATH=$PATH:$(brew --prefix)/bin:/home/vscode/.local/bin"
echo "alias dotfiles='cd /workspaces/.codespaces/.persistedshare/dotfiles'"
echo "alias k='kubectl'"
echo "alias ll='eza -la -g'"
echo "alias l='eza -la -g'"
# echo "alias logout='unset GITHUB_TOKEN'"
} >>~/.zshrc
fi
# Search for ZSH_THEME in ~/.zshrc and replace the value with "minimal"
# sed -i -E 's/ZSH_THEME=\"[a-z]*\"/ZSH_THEME=\"minimal\"/g' ~/.zshrc
# Install autosuggestions
log info "Installing zsh-autosuggestions"
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions || true
#@--------------------------------@#
# Adding auto-completions
#@--------------------------------@#
# Kubectl completions
kubectl completion zsh >"${fpath[1]}/_kubectl" || true
# Helm completions
helm completion zsh >"${fpath[1]}/_helm" || true
#@--------------------------------@#
# Create a GPG key
#@--------------------------------@#
export GPG_TTY
GPG_TTY=$(tty)
if test -t 0; then
log info "Generating GPG key"
gpg --batch --generate-key <.pass_key.metadata || true
log info "Listing GPG keys"
gpg --list-secret-keys --keyid-format LONG || true
else
log info "GPG key generation skipped. Not running in interactive mode"
fi
#@--------------------------------@#
# tmux config
#@--------------------------------@#
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm || true