Problem:
I was hoping this would be something simple to do. I currently have my script changing my directory among other things and I was hoping that I could make the script change the line using echo to always display the current directory. A simple example of what I had in mind was (Please note the directories being used are arbitrary and not actually true):
TL;DR;
I would just like to have a line at the top of my script that tells me the current directory. Then while the rest of the script is running and if the directory changes I would like that top line to change with it to always display the current directory
CODE:
echo -e "Current Directory $PWD"
echo -en "\e[0K\r Finding folder"
cd /home/accounts
echo -en "\r\033[0K Inside folder"
cd /apps/foo/bar
echo -e "\e[0K\r Welcome to the app, enjoy!"
Expected Output:
At initial execution (Before the 1st cd command is executed)
Line 1: Current Directory: /var/www/project
Line 2: Finding Folder
After the 1st cd command is executed
Line 1: Current Directory: /home/accounts
Line 2: Inside Folder
After the 2nd cd command is executed
Line 1: Current Directory: /apps/foo/bar
Line 2: Welcome to the app, enjoy!
cdin it.