diff options
| author | 2022-09-03 14:01:26 +0200 | |
|---|---|---|
| committer | 2022-09-03 05:01:26 -0700 | |
| commit | 2340e7e6e5eadf1fe920db4c276716d661a704b4 (patch) | |
| tree | ff81341489805bb774100a116f3a3d0b0c57c9cb | |
| parent | 98ecfc4f769c1085bcae0189fb9a5d639271306f (diff) | |
| download | bun-2340e7e6e5eadf1fe920db4c276716d661a704b4.tar.gz bun-2340e7e6e5eadf1fe920db4c276716d661a704b4.tar.zst bun-2340e7e6e5eadf1fe920db4c276716d661a704b4.zip | |
chore(install-script): automatically add bun to path - bash shell (#1168)
* chore(install-script): automatically add bun to path - bash shell
* add tildify
* chore: make requested changes
* fix: add equals true
Co-authored-by: Wallunen <44848747+Wallunen@users.noreply.github.com>
* fix: $XDG_CONFIG_HOME can be undefined
Co-authored-by: Wallunen <44848747+Wallunen@users.noreply.github.com>
Co-authored-by: Wallunen <44848747+Wallunen@users.noreply.github.com>
| -rw-r--r-- | src/cli/install.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cli/install.sh b/src/cli/install.sh index dc9f6aa4c..b9cc03cd3 100644 --- a/src/cli/install.sh +++ b/src/cli/install.sh @@ -226,6 +226,55 @@ zsh) done fi ;; +bash) + commands=( + "export $install_env=$quoted_install_dir" + "export PATH=$bin_env:\$PATH" + ) + + bash_configs=( + "$HOME/.bashrc" + "$HOME/.bash_profile" + ) + + if [[ ${XDG_CONFIG_HOME:-} ]]; then + bash_configs+=( + "$XDG_CONFIG_HOME/.bash_profile" + "$XDG_CONFIG_HOME/.bashrc" + "$XDG_CONFIG_HOME/bash_profile" + "$XDG_CONFIG_HOME/bashrc" + ) + fi + + set_manually=true + for bash_config in "${bash_configs[@]}"; do + tilde_bash_config=$(tildify "$bash_config") + + if [[ -w $bash_config ]]; then + { + echo -e '\n# bun' + + for command in "${commands[@]}"; do + echo "$command" + done + } >>"$bash_config" + + info "Added \"$tilde_bin_dir\" to \$PATH in \"$tilde_bash_config\"" + + refresh_command="source $bash_config" + set_manually=false + break + fi + done + + if [[ $set_manually = true ]]; then + echo "Manually add the directory to $tilde_bash_config (or similar):" + + for command in "${commands[@]}"; do + info_bold " $command" + done + fi + ;; *) echo 'Manually add the directory to ~/.bashrc (or similar):' info_bold " export $install_env=$quoted_install_dir" |
