This issue is specific to MAC OS.
This is the code in the bash profile. Just updating the current directory path in the prompt
function __get_current_dir() {
pwd
}
export PS1="\u@\h:--$(__get_current_dir)--\W$ "
Below is the behavior observed.
dummy@mac:--/Users/dummy--~$ pwd
/Users/dummy
dummy@mac:--/Users/dummy--~$ cd Desktop/
dummy@mac:--/Users/dummy--Desktop$ pwd
/Users/dummy/Desktop
dummy@mac:--/Users/dummy--Desktop$ cd ../Documents/
dummy@mac:--/Users/dummy--Documents$ pwd
/Users/dummy/Documents
dummy@mac:--/Users/dummy--Documents$
The output seen while executing pwd
in the terminal shows proper path, but the same pwd
evaluated in __get_current_dir
is stuck with the path loaded when the terminal was opened the first time. The same code works properly in the ubuntu
system.
Is there any fix for this ? The function __get_current_dir
has a bit more code in it and it's logic is specific to the current directory. Since the pwd
is not working here, the result of that function is wrong.