Skip to content

Commit

Permalink
Fix interpreter and improve install path detection (#611)
Browse files Browse the repository at this point in the history
Change interpreter from `[[` to `[` for better shell compatibility
(`sh`).

Check target path for `/bin/zsh` and `/usr/bin/zsh` instead of assuming
the path. This avoids the creation of nonsense paths. For instance, on
Debian the interpreter is located at `/usr/bin/zsh`, however, the path
is actually `/usr/local/share/zsh/site-functions`. Creating the folder
in `/usr/share/zsh` would be a source of confusion.

Fixes #610
  • Loading branch information
mafredri committed Sep 18, 2021
1 parent 4ead1d6 commit a72254d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
],
"scripts": {
"postinstall": "if [[ -e /opt/homebrew/bin/zsh ]]; then PURE_DEST=/opt/homebrew/share/zsh/site-functions npm run --silent postinstall-link && exit 0; elif [[ -e /usr/local/bin/zsh ]]; then PURE_DEST=/usr/local/share/zsh/site-functions npm run --silent postinstall-link && exit 0; elif [[ -e /bin/zsh ]] || [[ -e /usr/bin/zsh ]]; then PURE_DEST=/usr/share/zsh/site-functions npm run --silent postinstall-link && exit 0; fi; PURE_DEST=\"$PWD/functions\" npm run --silent postinstall-link && npm run --silent postinstall-fail-instructions",
"postinstall": "if [ -e /opt/homebrew/bin/zsh ]; then PURE_DEST=/opt/homebrew/share/zsh/site-functions npm run --silent postinstall-link && exit 0; elif [ -e /usr/local/bin/zsh ]; then PURE_DEST=/usr/local/share/zsh/site-functions npm run --silent postinstall-link && exit 0; elif [ -e /bin/zsh ] || [ -e /usr/bin/zsh ]; then for dest in /usr/share/zsh/site-functions /usr/local/share/zsh/site-functions; do if [ -d $dest ]; then PURE_DEST=$dest npm run --silent postinstall-link && exit 0; fi; done; fi; PURE_DEST=\"$PWD/functions\" npm run --silent postinstall-link && npm run --silent postinstall-fail-instructions",
"postinstall-link": "mkdir -p \"$PURE_DEST\" && ln -sf \"$PWD/pure.zsh\" \"$PURE_DEST/prompt_pure_setup\" && ln -sf \"$PWD/async.zsh\" \"$PURE_DEST/async\"",
"postinstall-fail-instructions": "echo \"\\nERROR: Could not automagically symlink the prompt. You can either:\\n\\n1. Add the following to your \\`.zshrc\\`:\\n\\n fpath+=('$PWD/functions')\\n\\n2. Or check out the readme on how to do it manually: https://github.com/sindresorhus/pure#manually\"",
"version": "sed -i '' -e 's/prompt_pure_state\\[version\\]=.*/prompt_pure_state[version]=\"'\"$npm_package_version\"'\"/' pure.zsh && git add pure.zsh"
Expand Down

0 comments on commit a72254d

Please sign in to comment.