-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_wsl.sh
244 lines (200 loc) · 5.21 KB
/
setup_wsl.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
# Check if running in WSL
if ! grep -q Microsoft /proc/version; then
echo "This script must be run in WSL"
exit 1
fi
# Update and upgrade system packages
echo "Updating system packages..."
sudo apt update && sudo apt upgrade -y
# Install required packages
echo "Installing required packages..."
sudo apt install -y zsh fzf
# Change default shell to zsh
echo "Changing default shell to zsh..."
chsh -s $(which zsh)
# Configure sudo without password
echo "Configuring sudo privileges..."
# Note: Replace $USER with your actual username if this doesn't work
# For example: echo "john ALL=(ALL) NOPASSWD: ALL" | sudo EDITOR='tee -a' visudo
echo "$USER ALL=(ALL) NOPASSWD: ALL" | sudo EDITOR='tee -a' visudo
# Install starship
echo "Installing starship prompt..."
curl -sS https://starship.rs/install.sh | sh
# Create starship config directory and file
mkdir -p ~/.config
touch ~/.config/starship.toml
# Configure starship
cat > ~/.config/starship.toml << 'EOL'
# Your starship configuration here
[status]
style = "red bold"
symbol = "💥 "
format = '[\[$symbol$status\]]($style) '
disabled = false
[helm]
format = 'via [$symbol($version )]($style)'
symbol = '⎈ '
style = 'bold white'
disabled = false
detect_extensions = []
detect_files = [
'helmfile.yaml',
'Chart.yaml',
]
detect_folders = []
[jobs]
symbol = '✦ '
threshold = 1
format = "[$symbol$number]($style) "
style = 'bold blue'
[terraform]
format = 'via [$symbol$workspace]($style) '
symbol = '💠 '
style = 'bold 105'
disabled = false
detect_extensions = [
'tf',
'hcl',
]
detect_files = []
detect_folders = ['.terraform']
[nodejs]
symbol = "⬢ "
style = "bold green"
disabled = false
[python]
pyenv_version_name = false
pyenv_prefix = 'pyenv '
python_binary = [
'python',
'python3',
'python2',
]
format = 'via [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'
version_format = 'v${raw}'
style = 'yellow bold'
symbol = '🐍 '
disabled = false
detect_extensions = ['py']
detect_files = [
'requirements.txt',
'.python-version',
'pyproject.toml',
'Pipfile',
'tox.ini',
'setup.py',
'__init__.py',
]
detect_folders = []
[vagrant]
format = 'via [$symbol($version )]($style)'
symbol = '⍱ '
style = 'cyan bold'
disabled = false
detect_extensions = []
detect_files = ['Vagrantfile']
detect_folders = []
[aws]
disabled = true
[username]
style_user = "purple bold"
style_root = "red bold"
format = "[$user]($style) "
disabled = true
show_always = true
[docker_context]
format = "[🐋 $context ](blue bold)"
disabled = false
[kubernetes]
symbol = '☸ '
format = '[$symbol$context \($namespace\)|](bold cyan) '
disabled = false
[gcloud]
disabled = true
[memory_usage]
format = "$symbol [${ram}( | )]($style) "
disabled = false
threshold = -1
symbol = "💾"
style = "bold dimmed green"
[git_branch]
format = " [$symbol$branch]($style) "
symbol = "🌱 "
style = "bold yellow"
[git_commit]
commit_hash_length = 8
style = "bold white"
[git_state]
format = '[\($state( $progress_current of $progress_total)\)]($style) '
[git_status]
conflicted = "🏳"
ahead = "🏎💨"
behind = "😰"
diverged = "😵"
untracked = "🤷"
stashed = "📦"
modified = "📝"
staged = '[++\($count\)](green)'
renamed = "👅"
deleted = "🗑"
[character]
success_symbol = "[➜](bold green) "
error_symbol = "[✗](bold red) "
[battery]
full_symbol = "🔋"
charging_symbol = "⚡️"
discharging_symbol = "💀"
[[battery.display]]
threshold = 15
style = "bold red"
[directory]
truncation_length = 5
format = "📂️ [$path]($style)[$read_only]($read_only_style) | "
read_only_style = 'red'
read_only = '🔒'
EOL
# Install zsh-autosuggestions
echo "Installing zsh-autosuggestions..."
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.zsh}/zsh-autosuggestions
# Configure .zshrc
cat > ~/.zshrc << 'EOL'
eval "$(starship init zsh)"
# Check if the current user is not root, then switch to root
if [[ $(id -u) -ne 0 ]]; then
sudo -i
fi
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/google-cloud-sdk/path.zsh.inc' ]; then . '/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/google-cloud-sdk/completion.zsh.inc' ]; then . '/google-cloud-sdk/completion.zsh.inc'; fi
alias k='kubectl'
# Ensure that the history is saved and shared across all sessions
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory
setopt sharehistory
# Useful keybindings for fzf
#export FZF_DEFAULT_COMMAND='fd --type f'
#export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
#export FZF_ALT_C_COMMAND='fd --type d'
#export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border'
# Enable fuzzy completion
#autoload -U compinit && compinit
#autoload -U bashcompinit && bashcompinit
#[ -f ~/.fzf.bash ] && source ~/.fzf.bash
source /usr/share/doc/fzf/examples/key-bindings.zsh
source /usr/share/doc/fzf/examples/completion.zsh
[[ $commands[kubectl] ]] && source <(kubectl completion zsh)
EOL
# Configure .bashrc to auto-start zsh
echo "Configuring .bashrc..."
cat >> ~/.bashrc << 'EOL'
# Auto-start zsh
if [ ! -z "$PS1" ]; then
exec /bin/zsh $*
fi
EOL
echo "Setup complete! Please restart your terminal."