/do.sh

https://github.com/gkmngrgn/config · Shell · 147 lines · 114 code · 23 blank · 10 comment · 14 complexity · 173872ca0fd1f461faefe85f0ee986db MD5 · raw file

  1. #!/usr/bin/env bash
  2. CONFIG_DIR="$HOME/.config"
  3. BIN_DIR="$HOME/.local/bin"
  4. print_help() {
  5. echo "Subcommands:"
  6. echo " > install copy your configuration files to your home folder."
  7. echo " > install_cli_apps install cli apps."
  8. }
  9. install() {
  10. if [ ! -d "$CONFIG_DIR" ]; then
  11. mkdir -p $CONFIG_DIR
  12. fi
  13. cp -r ./config/* $CONFIG_DIR
  14. find ./home \
  15. -maxdepth 1 \
  16. -iname '.*' \
  17. -type f \
  18. -exec cp {} $HOME \;
  19. if [ ! -e "$HOME/.oh-my-zsh" ]; then
  20. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  21. fi
  22. if [ ! -e "$HOME/.tmux/plugins/tpm" ]; then
  23. git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
  24. fi
  25. }
  26. install_cli_apps() {
  27. if [[ "$OSTYPE" == "linux-gnu"* ]]; then
  28. install_cli_apps_for_deb
  29. elif [[ "$OSTYPE" == "darwin"* ]]; then
  30. install_cli_apps_for_mac
  31. else
  32. echo -e "Unknown OS."
  33. fi
  34. }
  35. install_cli_apps_for_mac() {
  36. brew tap xwmx/taps # for nb
  37. brew install -q \
  38. bat \
  39. exa \
  40. git-delta \
  41. git-lfs \
  42. golang \
  43. himalaya \
  44. htop \
  45. hugo \
  46. jq \
  47. latexindent \
  48. mactex-no-gui \
  49. mosh \
  50. nb \
  51. nano \
  52. openssl \
  53. pass \
  54. pre-commit \
  55. ripgrep \
  56. tmux \
  57. toilet \
  58. # pyenv dependencies
  59. brew install -q \
  60. pyenv \
  61. readline \
  62. sqlite3 \
  63. xz \
  64. zlib
  65. # install nvm
  66. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  67. }
  68. install_cli_apps_for_deb() {
  69. if [ ! -d "$BIN_DIR" ]; then
  70. mkdir -p $BIN_DIR
  71. fi
  72. mkdir -p tmp
  73. cd tmp
  74. # install delta
  75. if hash delta 2>/dev/null; then
  76. echo -e "delta is already installed. Skipped."
  77. else
  78. curl -L -o delta.deb https://github.com/dandavison/delta/releases/download/0.11.3/git-delta_0.11.3_amd64.deb
  79. sudo dpkg -i delta.deb
  80. fi
  81. # install go
  82. if hash go 2>/dev/null; then
  83. echo -e "go is already installed. Skipped."
  84. else
  85. curl -L -o go.tar.gz https://go.dev/dl/go1.17.5.linux-amd64.tar.gz
  86. tar -xf go.tar.gz
  87. mv go $HOME
  88. fi
  89. # install jq
  90. if hash jq 2>/dev/null; then
  91. echo -e "jq is already installed. Skipped."
  92. else
  93. sudo apt install -y jq
  94. fi
  95. # install nvm
  96. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  97. # install pyenv
  98. if hash pyenv 2>/dev/null; then
  99. echo -e "pyenv is already installed. Skipped."
  100. else
  101. curl https://pyenv.run | bash
  102. fi
  103. # install ripgrep
  104. if hash rg 2>/dev/null; then
  105. echo -e "rg is already installed. Skipped."
  106. else
  107. curl -L -o ripgrep.deb https://github.com/BurntSushi/ripgrep/releases/download/13.0.0/ripgrep_13.0.0_amd64.deb
  108. sudo dpkg -i ripgrep.deb
  109. fi
  110. # install rust
  111. if hash rustc 2>/dev/null; then
  112. echo -e "rust is already installed. Skipped."
  113. else
  114. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  115. fi
  116. cd ..
  117. rm -rf tmp
  118. }
  119. if [ -z ${1} ]
  120. then
  121. print_help
  122. else
  123. ${@}
  124. fi