This is a script that move a bash file into homepage and load it with source command.
# update.sh
#!/bin/bash
cp -f $PWD/bash_profile ~/.bash_profile
source ~/.bash_profile
It does not work! It update file with cp -f $PWD/bash_profile ~/.bash_profile.
Inside ~/.bash_profile there is a new PS1 definition. File is updated but no changes happened until new window is opened. I need to run source ~/.bash_profile after script execution ...
Is it possibile to run source command inside bash script?
sourceinside the script instead of executing.bash_profile.echo "PS1=${PS1}" aftersource ~/.bash_profile, you will see it is changed. The changes get lost, when your scriptupdate.sh` is finished. You can usesourceto keep the changes valid in your current shell.