Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9060503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:14:48+00:00 2026-06-16T15:14:48+00:00

Im using shell script for some specific purposes and of the functions it has

  • 0

Im using shell script for some specific purposes and of the functions it has is to relad .bash_profile:

function refresh {
    source "$HOME/.bash_profile"
}

That same .bash_profile has this statement:

if [ -f "$HOME/.bash_prompt" ]; then
    source "$HOME/.bash_prompt"
fi

Which should also reload .bash_prompt; and it does, that prompt file contains values which should change display of the prompt (colors, text placement and such) but those values don’t change. They change only on new terminal window or if I explicitly call source "$HOME/.bash_prompt" inside terminal window.

Am I doing something wrong here?

Here is my .bash_prompt source:

# Colors
# Bunch of color codes

function print_before_the_prompt {

    # create a $fill of all screen width
    let fillsize=${COLUMNS}
    fill=""
    while [ "$fillsize" -gt "0" ]
    do
    fill="-${fill}" # fill with underscores to work on
    let fillsize=${fillsize}-1
    done

    printf "$txtrst$bakwht%s" "$fill"
    printf "\n$bldblk%s%s\n" "${PWD/$HOME/~}" "$(__git_ps1 "$txtrst [$txtblu%s$txtrst]")"

}

# Load Git completion and prompt
if [ -f "/usr/local/opt/git/etc/bash_completion.d/git-completion.bash" ]; then
    source "/usr/local/opt/git/etc/bash_completion.d/git-completion.bash"
fi
if [ -f "/usr/local/opt/git/etc/bash_completion.d/git-prompt.sh" ]; then
    source "/usr/local/opt/git/etc/bash_completion.d/git-prompt.sh"
fi

GIT_PS1_SHOWDIRTYSTATE=true
PROMPT_COMMAND=print_before_the_prompt
PS1="\[$txtred\]⦿\[$txtrst\] "
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:14:49+00:00Added an answer on June 16, 2026 at 3:14 pm

    You need to also source the script hosting the refresh function, instead of executing it. If you don’t do this, the environment is only changed during the execution of the script.

    Explanation: when you execute a script, it inherits its parent’s current environment (in this case: your shell) and it’s given its own environment. All environment changes in the script will only apply to the script itself and its children.

    However, when you source a script, all the changes and commands directly affects the parent’s environment.

    In general, it’s recommended to keep the scripts intended to be sourced separated to general purpose scripts. For example, you can have a dev.sh file containing special environment variables for a particular development project which needs some special variables.

    If you want a quick way to source your .bash_profile for your current shell, you can set an alias. Doing it by executing a script is impossible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a shell script that opens a ssh connection and creates an sqldump.
I am using the wc utility in a shell script that I run from
I've been having some problems with a shell script that changes a configuration file
I am writing a shell script that reads a properties file & perfroms some
how to extract some lines from a text file using unix shell script awk.
I want to use a shell script that I can call to set some
Below is my shell script that I am trying to execute using PLINK on
I am trying to make a very simple shell script that frees up some
I am reading one property file which contains some file paths using shell script.
I require some help in reading and updating a csv file using Shell script.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.