|
3 | 3 | # Supported OS'es are Windows/Cygwin, Windows/WSL, MacOS and Linux
|
4 | 4 | # Dev Note: Some funcs here are duplicated in zshcfg/0.zsh. This is by design
|
5 | 5 |
|
| 6 | +set -euo pipefail # See https://bertvv.github.io/cheat-sheets/Bash.html |
| 7 | +declare codeSetup golibsSetup pkgSetup miscSetup sdkSetup viSetup zshSetup settingsSetup utilSetup allSetup |
| 8 | +declare done_detect_os done_set_uservars done_set_homevars |
| 9 | +declare isCygwin isWsl isLinux |
| 10 | +declare trueHome dotfilesDir |
| 11 | + |
6 | 12 | usage() {
|
7 | 13 | echo "Usage: $0 [-c] [-g] [-p] [-v] [-t] [-u] [-z]" 1>&2
|
8 | 14 | exit 1
|
@@ -129,12 +135,13 @@ detect_dotfilesdir() {
|
129 | 135 | }
|
130 | 136 |
|
131 | 137 | detect_util() {
|
| 138 | + local hasCurl hasZip hasUnzip hasGit hasGo |
| 139 | + |
132 | 140 | hasCurl=$(command -v curl)
|
133 | 141 | hasZip=$(command -v zip)
|
134 | 142 | hasUnzip=$(command -v unzip)
|
135 | 143 | hasGit=$(command -v git)
|
136 | 144 | hasGo=$(command -v go)
|
137 |
| - ctags --help >/dev/null 2>&1 |
138 | 145 | [[ $? -ge 0 ]] && hasCtags=false || hasCtags=true
|
139 | 146 | [[ hasCurl ]] || echo "WARN: 'curl' not found. Setup may be incomplete"
|
140 | 147 | [[ hasCtags ]] || echo "WARN: 'ctags' not found or GNU version not installed"
|
@@ -245,7 +252,9 @@ gh_download_linux_release() {
|
245 | 252 | install_pkgs() {
|
246 | 253 | echo "- (install_pkgs) Installing packages..."
|
247 | 254 | if [[ $isMacos == true ]]; then
|
248 |
| - brew install coreutils parallel iproute2mac gnu-sed gnu-tar grep gzip fd jq ctags the_silver_searcher fortune cowsay node go rlwrap yarn neovim skim cmake deno ripgrep delve kubectl krew kube-ps1 gardener/tap/gardenctl-v2 docker openvpn |
| 255 | + brew install coreutils parallel iproute2mac gnu-sed gnu-tar grep gzip fd jq ctags the_silver_searcher fortune cowsay node go rlwrap yarn neovim skim cmake deno ripgrep delve kubectl krew kube-ps1 gardener/tap/gardenctl-v2 docker openvpn lazygit k9s |
| 256 | + brew tap johanhaleby/kubetail && brew install kubetail |
| 257 | + brew tap homebrew/cask-fonts && brew install --cask font-jetbrains-mono-nerd-font --cask font-symbols-only-nerd-font |
249 | 258 | elif [[ $isLinux == true ]]; then
|
250 | 259 | if [[ $isRedhat == true ]]; then
|
251 | 260 | install_pkgs_redhat
|
@@ -366,23 +375,31 @@ setup_vim() {
|
366 | 375 | initialize_vars
|
367 | 376 | echo "-- setup_vim"
|
368 | 377 |
|
369 |
| - nvimConfigDotfiles=$dotfilesDir/nvimcfg |
| 378 | + local nvimConfigDotfiles=$dotfilesDir/nvimcfg |
370 | 379 |
|
371 |
| - nvimConfig=$trueHome/.config/nvim |
372 |
| - rm $vimConfig 2>/dev/null |
| 380 | + local nvimConfig=$trueHome/.config/nvim |
| 381 | + local nvimShare=$trueHome/.local/share/nvim |
| 382 | + local nvimState=$trueHome/.local/state/nvim |
| 383 | + local nvimCache=$trueHome/.cache/nvim |
373 | 384 |
|
374 |
| - rm $trueHome/.vimrc 2>/dev/null |
375 |
| - rm $trueHome/_vimrc 2>/dev/null |
376 |
| - rm $trueHome/.ideavimrc 2>/dev/null |
377 |
| - rm $nvimConfig 2>/dev/null |
| 385 | + [[ -e "$trueHome/.vimrc" ]] && rm "$trueHome/.vimrc" |
| 386 | + [[ -e "$trueHome/_vimrc" ]] && rm "$trueHome/_vimrc" |
| 387 | + [[ -e "$trueHome/.ideavimrc" ]] && rm $trueHome/.ideavimrc |
378 | 388 |
|
379 | 389 | echo "Linking ideavimrc"
|
380 | 390 | ln $dotfilesDir/ideavimrc $trueHome/.ideavimrc
|
381 | 391 |
|
382 |
| - echo "Cloning LazyVim..." |
383 |
| - rm -rf $trueHome/.config/nvim |
384 |
| - git clone https://github.com/LazyVim/starter ~/.config/nvim |
385 |
| - ln -sf $nvimConfigDotfiles/customize.lua $nvimConfig/lua/plugins/customize.lua |
| 392 | + echo "Deleting (if present) $nvimConfig, $nvimShare, $nvimState, $nvimCache" |
| 393 | + [[ -d $nvimConfig ]] && echo "deleing $nvimConfig.." && rm -rf $nvimConfig |
| 394 | + [[ -d $nvimShare ]] && echo "deleing $nvimShare.." && rm -rf $nvimShare |
| 395 | + [[ -d $nvimState ]] && echo "deleing $nvimState.." && rm -rf $nvimState |
| 396 | + [[ -d $nvimCache ]] && echo "deleing $nvimCache.." && rm -rf $nvimCache |
| 397 | + |
| 398 | + echo "Installing nvchad.." |
| 399 | + git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1 |
| 400 | + git clone https://github.com/lenkite/nvchad_custom_config ~/.config/nvim/lua/custom |
| 401 | + NVCHAD_EXAMPLE_CONFIG=n nvim --headless +"TSUpdate vimdoc" +"q" |
| 402 | + |
386 | 403 | }
|
387 | 404 |
|
388 | 405 | setup_misc() {
|
@@ -422,7 +439,7 @@ setup_util() {
|
422 | 439 | }
|
423 | 440 |
|
424 | 441 | setup_settings() {
|
425 |
| - echo "- setup_settings" |
| 442 | + echo "- setup_settings (OS settings)" |
426 | 443 | hasTmux=$(command -v tmux)
|
427 | 444 | if [[ $isMacos ]]; then
|
428 | 445 | [[ $hasTmux ]] && brew install tmux
|
@@ -451,13 +468,15 @@ setup_sdk() {
|
451 | 468 | setup_zsh() {
|
452 | 469 | initialize_vars
|
453 | 470 | echo "- setup_zsh"
|
| 471 | + echo "Copying zsh history to /tmp..." |
| 472 | + cp $trueHome/.zsh_history /tmp |
454 | 473 | echo "Deleting all existing .z* files from home directory.."
|
455 |
| - rm $trueHome/.zshrc 2>/dev/null |
456 |
| - rm $trueHome/.zprofile 2>/dev/null |
457 |
| - rm $trueHome/.zshenv 2>/dev/null |
458 |
| - rm $trueHome/.zlogin 2>/dev/null |
459 |
| - rm $trueHome/.zlogout 2>/dev/null |
460 |
| - rm $trueHome/.zpreztorc 2>/dev/null |
| 474 | + [[ -f "$trueHome/.zshrc" ]] && rm $trueHome/.zshrc |
| 475 | + [[ -f "$trueHome/.zprofile" ]] && rm $trueHome/.zprofile 2>/dev/null |
| 476 | + [[ -f "$trueHome/.zshenv" ]] && rm $trueHome/.zshenv 2>/dev/null |
| 477 | + [[ -f "$trueHome/.zlogin" ]] && rm $trueHome/.zlogin 3>/dev/null |
| 478 | + [[ -f "$trueHome/.zlogout" ]] && rm $trueHome/.zlogout 2>/dev/null |
| 479 | + [[ -f "$trueHome/.zpreztorc" ]] && rm $trueHome/.zpreztorc 2>/dev/null |
461 | 480 | echo "Deleted all existing .z* files from home directory.."
|
462 | 481 |
|
463 | 482 | zshCfgDir=$dotfilesDir/zshcfg
|
@@ -486,23 +505,16 @@ setup_zsh() {
|
486 | 505 | rm -rf $trueHome/.zgen
|
487 | 506 | fi
|
488 | 507 |
|
489 |
| - # if [[ $hasCurl ]]; then |
490 |
| - # echo "Installing antigen" |
491 |
| - # local antigenDir=$trueHome/.antigen |
492 |
| - # [[ -d $antigenDir ]] || mkdir -p $antigenDir |
493 |
| - # local antigenLoc=$antigenDir/antigen.zsh |
494 |
| - # [[ -f $antigenLoc ]] && rm -f $antigenLoc |
495 |
| - # curl -L git.io/antigen > $antigenLoc |
496 |
| - # else |
497 |
| - # echo "ERROR: Could not find git and hence couldn't clone zgen :(" |
498 |
| - # fi |
499 |
| - |
500 | 508 | if [ -d $trueHome/.zgen -a -d $trueHome/.zgen/.git ]; then
|
501 | 509 | git -C $trueHome/.zgen reset --hard
|
502 | 510 | git -C $trueHome/.zgen pull
|
503 | 511 | else
|
504 | 512 | git clone https://github.com/tarjoilija/zgen.git "${trueHome}/.zgen"
|
505 | 513 | fi
|
| 514 | + echo "Coping back .zsh_history to $trueHome..." |
| 515 | + cp /tmp/.zsh_history $trueHome/ |
| 516 | + |
| 517 | + echo "--setup_zsh is done" |
506 | 518 |
|
507 | 519 | }
|
508 | 520 |
|
|
0 commit comments