FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Include commad to load shell configuration after installation for Linux and MacOS by aquib-sh · Pull Request #100 · AssemblyAI/assemblyai-cli · GitHub

This repository was archived by the owner on Aug 12, 2026. It is now read-only.
/ assemblyai-cli Public archive

Include commad to load shell configuration after installation for Linux and MacOS - #100

Open
aquib-sh wants to merge 2 commits into
AssemblyAI:mainfrom
aquib-sh:documentation
Open

Include commad to load shell configuration after installation for Linux and MacOS#100
aquib-sh wants to merge 2 commits into
AssemblyAI:mainfrom
aquib-sh:documentation

Conversation

Copy link
Copy Markdown

Why

The PATH environment variable does not get updated after running the install.sh script,
As a result the user would have to manually source the shell configuration file in order to update the environment variables or open a new terminal session.

Even though the below conditional statement to source the configuration file is present in install.sh at the end of file

if [ -f "$HOME/.bashrc" ]; then
	source "$HOME/.bashrc"
fi
if [ -f "$HOME/.zshrc" ]; then
	zsh
	source "$HOME/.zshrc"
fi

But it won't work (in some cases it will) because shell scripts by default run in a non interactive shell and source command only works when the shell is in interactive mode. Which means the environment variables declared or updated while running the install.sh file won't be reflected in the user's shell.

What is changing

A case statement has been added below the previous command which was used to run install.sh so that the configuration can be sourced in the interactive shell and the environment variables are updated in the same shell instance.

case "$SHELL" in
    *bash*)
        if [ -f "$HOME/.bashrc" ]; then
            # if the shell contains "bash" and .bashrc is present
            source $HOME/.bashrc
        fi
        ;;
    *zsh*)
        if [ -f "$HOME/.zshrc" ]; then
            # if the shell contains "zsh" and .zshrc is present
            source $HOME/.zshrc
        fi
        ;;
    *)
        echo "Unknown shell or required configuration file not found."
        ;;
esac

Why did I use this approach to check shell type?

You might notice I used "$SHELL" in *bash* approach which basically is checking a sub string instead of explicitly doing $SHELL=="/bin/bash"
This approach have some added advantages to it instead of explicit check of shell path'

  • It would work even if the user shell is /usr/bin/bash or /usr/bin/zsh
  • It would work if the user has set it's customized the shell path and not using the traditional /bin/bash or /usr/bin/bash

How to test

To test you will first need to uninstall the existing install (if present) using
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/AssemblyAI/assemblyai-cli/main/uninstall.sh)" and load the latest shell configuration using the above command we used before.

Verify that the assemblyai is not within the PATH entering it on terminal

Now Install the script again using /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/AssemblyAI/assemblyai-cli/main/install.sh)" and run the command for loading the shell configuration we used before.

As you can see below it updated the environment variable and now the user can access the assemblyai

aquib-sh changed the title Include commad to load shell configuration after installation Include commad to load shell configuration after installation for Linux and MacOS Jun 29, 2023

Copy link
Copy Markdown
Contributor

Thanks for the PR. I think we can also improve some of the messaging on install.sh. We'll check this out over the next few days.

Copy link
Copy Markdown
Author

Did you guys check out? @albtsantos

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL