install.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. #!/bin/sh
  2. #
  3. # This script should be run via curl:
  4. # sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  5. # or via wget:
  6. # sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  7. # or via fetch:
  8. # sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  9. #
  10. # As an alternative, you can first download the install script and run it afterwards:
  11. # wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
  12. # sh install.sh
  13. #
  14. # You can tweak the install behavior by setting variables when running the script. For
  15. # example, to change the path to the Oh My Zsh repository:
  16. # ZSH=~/.zsh sh install.sh
  17. #
  18. # Respects the following environment variables:
  19. # ZDOTDIR - path to Zsh dotfiles directory (default: unset). See [1][2]
  20. # [1] https://zsh.sourceforge.io/Doc/Release/Parameters.html#index-ZDOTDIR
  21. # [2] https://zsh.sourceforge.io/Doc/Release/Files.html#index-ZDOTDIR_002c-use-of
  22. # ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
  23. # REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
  24. # REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
  25. # BRANCH - branch to check out immediately after install (default: master)
  26. #
  27. # Other options:
  28. # CHSH - 'no' means the installer will not change the default shell (default: yes)
  29. # RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)
  30. # KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)
  31. #
  32. # You can also pass some arguments to the install script to set some these options:
  33. # --skip-chsh: has the same behavior as setting CHSH to 'no'
  34. # --unattended: sets both CHSH and RUNZSH to 'no'
  35. # --keep-zshrc: sets KEEP_ZSHRC to 'yes'
  36. # For example:
  37. # sh install.sh --unattended
  38. # or:
  39. # sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
  40. #
  41. set -e
  42. # Make sure important variables exist if not already defined
  43. #
  44. # $USER is defined by login(1) which is not always executed (e.g. containers)
  45. # POSIX: https://pubs.opengroup.org/onlinepubs/009695299/utilities/id.html
  46. USER=${USER:-$(id -u -n)}
  47. # $HOME is defined at the time of login, but it could be unset. If it is unset,
  48. # a tilde by itself (~) will not be expanded to the current user's home directory.
  49. # POSIX: https://pubs.opengroup.org/onlinepubs/009696899/basedefs/xbd_chap08.html#tag_08_03
  50. HOME="${HOME:-$(getent passwd $USER 2>/dev/null | cut -d: -f6)}"
  51. # macOS does not have getent, but this works even if $HOME is unset
  52. HOME="${HOME:-$(eval echo ~$USER)}"
  53. # Track if $ZSH was provided
  54. custom_zsh=${ZSH:+yes}
  55. # Use $zdot to keep track of where the directory is for zsh dotfiles
  56. # To check if $ZDOTDIR was provided, explicitly check for $ZDOTDIR
  57. zdot="${ZDOTDIR:-$HOME}"
  58. # Default value for $ZSH
  59. # a) if $ZDOTDIR is supplied and not $HOME: $ZDOTDIR/ohmyzsh
  60. # b) otherwise, $HOME/.oh-my-zsh
  61. if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then
  62. ZSH="${ZSH:-$ZDOTDIR/ohmyzsh}"
  63. fi
  64. ZSH="${ZSH:-$HOME/.oh-my-zsh}"
  65. # Default settings
  66. REPO=${REPO:-ohmyzsh/ohmyzsh}
  67. REMOTE=${REMOTE:-https://github.com/${REPO}.git}
  68. BRANCH=${BRANCH:-master}
  69. # Other options
  70. CHSH=${CHSH:-yes}
  71. RUNZSH=${RUNZSH:-yes}
  72. KEEP_ZSHRC=${KEEP_ZSHRC:-no}
  73. command_exists() {
  74. command -v "$@" >/dev/null 2>&1
  75. }
  76. user_can_sudo() {
  77. # Check if sudo is installed
  78. command_exists sudo || return 1
  79. # Termux can't run sudo, so we can detect it and exit the function early.
  80. case "$PREFIX" in
  81. *com.termux*) return 1 ;;
  82. esac
  83. # The following command has 3 parts:
  84. #
  85. # 1. Run `sudo` with `-v`. Does the following:
  86. # • with privilege: asks for a password immediately.
  87. # • without privilege: exits with error code 1 and prints the message:
  88. # Sorry, user <username> may not run sudo on <hostname>
  89. #
  90. # 2. Pass `-n` to `sudo` to tell it to not ask for a password. If the
  91. # password is not required, the command will finish with exit code 0.
  92. # If one is required, sudo will exit with error code 1 and print the
  93. # message:
  94. # sudo: a password is required
  95. #
  96. # 3. Check for the words "may not run sudo" in the output to really tell
  97. # whether the user has privileges or not. For that we have to make sure
  98. # to run `sudo` in the default locale (with `LANG=`) so that the message
  99. # stays consistent regardless of the user's locale.
  100. #
  101. ! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo"
  102. }
  103. # The [ -t 1 ] check only works when the function is not called from
  104. # a subshell (like in `$(...)` or `(...)`, so this hack redefines the
  105. # function at the top level to always return false when stdout is not
  106. # a tty.
  107. if [ -t 1 ]; then
  108. is_tty() {
  109. true
  110. }
  111. else
  112. is_tty() {
  113. false
  114. }
  115. fi
  116. # This function uses the logic from supports-hyperlinks[1][2], which is
  117. # made by Kat Marchán (@zkat) and licensed under the Apache License 2.0.
  118. # [1] https://github.com/zkat/supports-hyperlinks
  119. # [2] https://crates.io/crates/supports-hyperlinks
  120. #
  121. # Copyright (c) 2021 Kat Marchán
  122. #
  123. # Licensed under the Apache License, Version 2.0 (the "License");
  124. # you may not use this file except in compliance with the License.
  125. # You may obtain a copy of the License at
  126. #
  127. # http://www.apache.org/licenses/LICENSE-2.0
  128. #
  129. # Unless required by applicable law or agreed to in writing, software
  130. # distributed under the License is distributed on an "AS IS" BASIS,
  131. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  132. # See the License for the specific language governing permissions and
  133. # limitations under the License.
  134. supports_hyperlinks() {
  135. # $FORCE_HYPERLINK must be set and be non-zero (this acts as a logic bypass)
  136. if [ -n "$FORCE_HYPERLINK" ]; then
  137. [ "$FORCE_HYPERLINK" != 0 ]
  138. return $?
  139. fi
  140. # If stdout is not a tty, it doesn't support hyperlinks
  141. is_tty || return 1
  142. # DomTerm terminal emulator (domterm.org)
  143. if [ -n "$DOMTERM" ]; then
  144. return 0
  145. fi
  146. # VTE-based terminals above v0.50 (Gnome Terminal, Guake, ROXTerm, etc)
  147. if [ -n "$VTE_VERSION" ]; then
  148. [ $VTE_VERSION -ge 5000 ]
  149. return $?
  150. fi
  151. # If $TERM_PROGRAM is set, these terminals support hyperlinks
  152. case "$TERM_PROGRAM" in
  153. Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
  154. esac
  155. # kitty supports hyperlinks
  156. if [ "$TERM" = xterm-kitty ]; then
  157. return 0
  158. fi
  159. # Windows Terminal also supports hyperlinks
  160. if [ -n "$WT_SESSION" ]; then
  161. return 0
  162. fi
  163. # Konsole supports hyperlinks, but it's an opt-in setting that can't be detected
  164. # https://github.com/ohmyzsh/ohmyzsh/issues/10964
  165. # if [ -n "$KONSOLE_VERSION" ]; then
  166. # return 0
  167. # fi
  168. return 1
  169. }
  170. # Adapted from code and information by Anton Kochkov (@XVilka)
  171. # Source: https://gist.github.com/XVilka/8346728
  172. supports_truecolor() {
  173. case "$COLORTERM" in
  174. truecolor|24bit) return 0 ;;
  175. esac
  176. case "$TERM" in
  177. iterm |\
  178. tmux-truecolor |\
  179. linux-truecolor |\
  180. xterm-truecolor |\
  181. screen-truecolor) return 0 ;;
  182. esac
  183. return 1
  184. }
  185. fmt_link() {
  186. # $1: text, $2: url, $3: fallback mode
  187. if supports_hyperlinks; then
  188. printf '\033]8;;%s\033\\%s\033]8;;\033\\\n' "$2" "$1"
  189. return
  190. fi
  191. case "$3" in
  192. --text) printf '%s\n' "$1" ;;
  193. --url|*) fmt_underline "$2" ;;
  194. esac
  195. }
  196. fmt_underline() {
  197. is_tty && printf '\033[4m%s\033[24m\n' "$*" || printf '%s\n' "$*"
  198. }
  199. # shellcheck disable=SC2016 # backtick in single-quote
  200. fmt_code() {
  201. is_tty && printf '`\033[2m%s\033[22m`\n' "$*" || printf '`%s`\n' "$*"
  202. }
  203. fmt_error() {
  204. printf '%sError: %s%s\n' "${FMT_BOLD}${FMT_RED}" "$*" "$FMT_RESET" >&2
  205. }
  206. setup_color() {
  207. # Only use colors if connected to a terminal
  208. if ! is_tty; then
  209. FMT_RAINBOW=""
  210. FMT_RED=""
  211. FMT_GREEN=""
  212. FMT_YELLOW=""
  213. FMT_BLUE=""
  214. FMT_BOLD=""
  215. FMT_RESET=""
  216. return
  217. fi
  218. if supports_truecolor; then
  219. FMT_RAINBOW="
  220. $(printf '\033[38;2;255;0;0m')
  221. $(printf '\033[38;2;255;97;0m')
  222. $(printf '\033[38;2;247;255;0m')
  223. $(printf '\033[38;2;0;255;30m')
  224. $(printf '\033[38;2;77;0;255m')
  225. $(printf '\033[38;2;168;0;255m')
  226. $(printf '\033[38;2;245;0;172m')
  227. "
  228. else
  229. FMT_RAINBOW="
  230. $(printf '\033[38;5;196m')
  231. $(printf '\033[38;5;202m')
  232. $(printf '\033[38;5;226m')
  233. $(printf '\033[38;5;082m')
  234. $(printf '\033[38;5;021m')
  235. $(printf '\033[38;5;093m')
  236. $(printf '\033[38;5;163m')
  237. "
  238. fi
  239. FMT_RED=$(printf '\033[31m')
  240. FMT_GREEN=$(printf '\033[32m')
  241. FMT_YELLOW=$(printf '\033[33m')
  242. FMT_BLUE=$(printf '\033[34m')
  243. FMT_BOLD=$(printf '\033[1m')
  244. FMT_RESET=$(printf '\033[0m')
  245. }
  246. setup_ohmyzsh() {
  247. # Prevent the cloned repository from having insecure permissions. Failing to do
  248. # so causes compinit() calls to fail with "command not found: compdef" errors
  249. # for users with insecure umasks (e.g., "002", allowing group writability). Note
  250. # that this will be ignored under Cygwin by default, as Windows ACLs take
  251. # precedence over umasks except for filesystems mounted with option "noacl".
  252. umask g-w,o-w
  253. echo "${FMT_BLUE}Cloning Oh My Zsh...${FMT_RESET}"
  254. command_exists git || {
  255. fmt_error "git is not installed"
  256. exit 1
  257. }
  258. ostype=$(uname)
  259. if [ -z "${ostype%CYGWIN*}" ] && git --version | grep -Eq 'msysgit|windows'; then
  260. fmt_error "Windows/MSYS Git is not supported on Cygwin"
  261. fmt_error "Make sure the Cygwin git package is installed and is first on the \$PATH"
  262. exit 1
  263. fi
  264. # Manual clone with git config options to support git < v1.7.2
  265. git init --quiet "$ZSH" && cd "$ZSH" \
  266. && git config core.eol lf \
  267. && git config core.autocrlf false \
  268. && git config fsck.zeroPaddedFilemode ignore \
  269. && git config fetch.fsck.zeroPaddedFilemode ignore \
  270. && git config receive.fsck.zeroPaddedFilemode ignore \
  271. && git config oh-my-zsh.remote origin \
  272. && git config oh-my-zsh.branch "$BRANCH" \
  273. && git remote add origin "$REMOTE" \
  274. && git fetch --depth=1 origin \
  275. && git checkout -b "$BRANCH" "origin/$BRANCH" || {
  276. [ ! -d "$ZSH" ] || {
  277. cd -
  278. rm -rf "$ZSH" 2>/dev/null
  279. }
  280. fmt_error "git clone of oh-my-zsh repo failed"
  281. exit 1
  282. }
  283. # Exit installation directory
  284. cd -
  285. echo
  286. }
  287. setup_zshrc() {
  288. # Keep most recent old .zshrc at .zshrc.pre-oh-my-zsh, and older ones
  289. # with datestamp of installation that moved them aside, so we never actually
  290. # destroy a user's original zshrc
  291. echo "${FMT_BLUE}Looking for an existing zsh config...${FMT_RESET}"
  292. # Must use this exact name so uninstall.sh can find it
  293. OLD_ZSHRC="$zdot/.zshrc.pre-oh-my-zsh"
  294. if [ -f "$zdot/.zshrc" ] || [ -h "$zdot/.zshrc" ]; then
  295. # Skip this if the user doesn't want to replace an existing .zshrc
  296. if [ "$KEEP_ZSHRC" = yes ]; then
  297. echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}"
  298. return
  299. fi
  300. if [ -e "$OLD_ZSHRC" ]; then
  301. OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
  302. if [ -e "$OLD_OLD_ZSHRC" ]; then
  303. fmt_error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}"
  304. fmt_error "re-run the installer again in a couple of seconds"
  305. exit 1
  306. fi
  307. mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}"
  308. echo "${FMT_YELLOW}Found old .zshrc.pre-oh-my-zsh." \
  309. "${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}"
  310. fi
  311. echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}"
  312. mv "$zdot/.zshrc" "$OLD_ZSHRC"
  313. fi
  314. echo "${FMT_GREEN}Using the Oh My Zsh template file and adding it to $zdot/.zshrc.${FMT_RESET}"
  315. # Modify $ZSH variable in .zshrc directory to use the literal $ZDOTDIR or $HOME
  316. omz="$ZSH"
  317. if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then
  318. omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|")
  319. fi
  320. omz=$(echo "$omz" | sed "s|^$HOME/|\$HOME/|")
  321. sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp"
  322. mv -f "$zdot/.zshrc-omztemp" "$zdot/.zshrc"
  323. echo
  324. }
  325. setup_shell() {
  326. # Skip setup if the user wants or stdin is closed (not running interactively).
  327. if [ "$CHSH" = no ]; then
  328. return
  329. fi
  330. # If this user's login shell is already "zsh", do not attempt to switch.
  331. if [ "$(basename -- "$SHELL")" = "zsh" ]; then
  332. return
  333. fi
  334. # If this platform doesn't provide a "chsh" command, bail out.
  335. if ! command_exists chsh; then
  336. cat <<EOF
  337. I can't change your shell automatically because this system does not have chsh.
  338. ${FMT_BLUE}Please manually change your default shell to zsh${FMT_RESET}
  339. EOF
  340. return
  341. fi
  342. echo "${FMT_BLUE}Time to change your default shell to zsh:${FMT_RESET}"
  343. # Prompt for user choice on changing the default login shell
  344. printf '%sDo you want to change your default shell to zsh? [Y/n]%s ' \
  345. "$FMT_YELLOW" "$FMT_RESET"
  346. read -r opt
  347. case $opt in
  348. y*|Y*|"") ;;
  349. n*|N*) echo "Shell change skipped."; return ;;
  350. *) echo "Invalid choice. Shell change skipped."; return ;;
  351. esac
  352. # Check if we're running on Termux
  353. case "$PREFIX" in
  354. *com.termux*) termux=true; zsh=zsh ;;
  355. *) termux=false ;;
  356. esac
  357. if [ "$termux" != true ]; then
  358. # Test for the right location of the "shells" file
  359. if [ -f /etc/shells ]; then
  360. shells_file=/etc/shells
  361. elif [ -f /usr/share/defaults/etc/shells ]; then # Solus OS
  362. shells_file=/usr/share/defaults/etc/shells
  363. else
  364. fmt_error "could not find /etc/shells file. Change your default shell manually."
  365. return
  366. fi
  367. # Get the path to the right zsh binary
  368. # 1. Use the most preceding one based on $PATH, then check that it's in the shells file
  369. # 2. If that fails, get a zsh path from the shells file, then check it actually exists
  370. if ! zsh=$(command -v zsh) || ! grep -qx "$zsh" "$shells_file"; then
  371. if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -n 1) || [ ! -f "$zsh" ]; then
  372. fmt_error "no zsh binary found or not present in '$shells_file'"
  373. fmt_error "change your default shell manually."
  374. return
  375. fi
  376. fi
  377. fi
  378. # We're going to change the default shell, so back up the current one
  379. if [ -n "$SHELL" ]; then
  380. echo "$SHELL" > "$zdot/.shell.pre-oh-my-zsh"
  381. else
  382. grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > "$zdot/.shell.pre-oh-my-zsh"
  383. fi
  384. echo "Changing your shell to $zsh..."
  385. # Check if user has sudo privileges to run `chsh` with or without `sudo`
  386. #
  387. # This allows the call to succeed without password on systems where the
  388. # user does not have a password but does have sudo privileges, like in
  389. # Google Cloud Shell.
  390. #
  391. # On systems that don't have a user with passwordless sudo, the user will
  392. # be prompted for the password either way, so this shouldn't cause any issues.
  393. #
  394. if user_can_sudo; then
  395. sudo -k chsh -s "$zsh" "$USER" # -k forces the password prompt
  396. else
  397. chsh -s "$zsh" "$USER" # run chsh normally
  398. fi
  399. # Check if the shell change was successful
  400. if [ $? -ne 0 ]; then
  401. fmt_error "chsh command unsuccessful. Change your default shell manually."
  402. else
  403. export SHELL="$zsh"
  404. echo "${FMT_GREEN}Shell successfully changed to '$zsh'.${FMT_RESET}"
  405. fi
  406. echo
  407. }
  408. # shellcheck disable=SC2183 # printf string has more %s than arguments ($FMT_RAINBOW expands to multiple arguments)
  409. print_success() {
  410. printf '%s %s__ %s %s %s %s %s__ %s\n' $FMT_RAINBOW $FMT_RESET
  411. printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $FMT_RAINBOW $FMT_RESET
  412. printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $FMT_RAINBOW $FMT_RESET
  413. printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $FMT_RAINBOW $FMT_RESET
  414. printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $FMT_RAINBOW $FMT_RESET
  415. printf '%s %s %s %s /____/ %s %s %s %s....is now installed!%s\n' $FMT_RAINBOW $FMT_GREEN $FMT_RESET
  416. printf '\n'
  417. printf '\n'
  418. printf "%s %s %s\n" "Before you scream ${FMT_BOLD}${FMT_YELLOW}Oh My Zsh!${FMT_RESET} look over the" \
  419. "$(fmt_code "$(fmt_link ".zshrc" "file://$zdot/.zshrc" --text)")" \
  420. "file to select plugins, themes, and options."
  421. printf '\n'
  422. printf '%s\n' "• Follow us on Twitter: $(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
  423. printf '%s\n' "• Join our Discord community: $(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
  424. printf '%s\n' "• Get stickers, t-shirts, coffee mugs and more: $(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
  425. printf '%s\n' $FMT_RESET
  426. }
  427. main() {
  428. # Run as unattended if stdin is not a tty
  429. if [ ! -t 0 ]; then
  430. RUNZSH=no
  431. CHSH=no
  432. fi
  433. # Parse arguments
  434. while [ $# -gt 0 ]; do
  435. case $1 in
  436. --unattended) RUNZSH=no; CHSH=no ;;
  437. --skip-chsh) CHSH=no ;;
  438. --keep-zshrc) KEEP_ZSHRC=yes ;;
  439. esac
  440. shift
  441. done
  442. setup_color
  443. if ! command_exists zsh; then
  444. echo "${FMT_YELLOW}Zsh is not installed.${FMT_RESET} Please install zsh first."
  445. exit 1
  446. fi
  447. if [ -d "$ZSH" ]; then
  448. echo "${FMT_YELLOW}The \$ZSH folder already exists ($ZSH).${FMT_RESET}"
  449. if [ "$custom_zsh" = yes ]; then
  450. cat <<EOF
  451. You ran the installer with the \$ZSH setting or the \$ZSH variable is
  452. exported. You have 3 options:
  453. 1. Unset the ZSH variable when calling the installer:
  454. $(fmt_code "ZSH= sh install.sh")
  455. 2. Install Oh My Zsh to a directory that doesn't exist yet:
  456. $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
  457. 3. (Caution) If the folder doesn't contain important information,
  458. you can just remove it with $(fmt_code "rm -r $ZSH")
  459. EOF
  460. else
  461. echo "You'll need to remove it if you want to reinstall."
  462. fi
  463. exit 1
  464. fi
  465. # Create ZDOTDIR folder structure if it doesn't exist
  466. if [ -n "$ZDOTDIR" ]; then
  467. mkdir -p "$ZDOTDIR"
  468. fi
  469. setup_ohmyzsh
  470. setup_zshrc
  471. setup_shell
  472. print_success
  473. if [ $RUNZSH = no ]; then
  474. echo "${FMT_YELLOW}Run zsh to try it out.${FMT_RESET}"
  475. exit
  476. fi
  477. exec zsh -l
  478. }
  479. main "$@"