0

I have installed Git Aware Prompt. I have followed the instructions in the project readme file and customised my prompt in ~./bash_profile by adding the following lines:

export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"

export PS1="\[\$txtgrn\]$(pwd) \[\$txtcyn\]\$git_branch\[\$txtred\]\$git_dirty\[\$txtrst\] \n\$ "

However my cwd is not updated when I cd:

/Users/pkaramol/Workspace
$ pwd
/Users/pkaramol/Workspace
/Users/pkaramol/Workspace
$ cd terraxamples/
/Users/pkaramol/Workspace
$ source ~/.bash_profile
/Users/pkaramol/Workspace/terraxamples

I have also tried using the env var $(PWD) instead of the command pwd.

Any idea why this is happening?

I am using iTerm2 in macOS Mojave 10.14.5.

This is what I am getting after re-launching iTerm2:

Last login: Mon May 27 12:28:26 on ttys002
/Users/pkaramol
$ cd Workspace/
/Users/pkaramol
$
  • Welcome to Ask Different :) Did you relaunch iTerm? Try running source ~/.bash_profile. See if either of the two works. – Nimesh Neema May 27 at 10:52
  • thanks for the welcome; I have tried both and the problem persists. Check my edit on the question too – pkaramol May 27 at 10:55
  • Try running git branch and see if there's an initialized Git repository in the directory, with at least one commit. – Nimesh Neema May 27 at 10:58
  • There is no .git repo on the particular dir but shouldn't pwd be working either way? – pkaramol May 27 at 10:59
  • Do you mind editing the question and pasting the contents of your ~/.bash_profile? Something there is causing the previous directory name to get echoed on the terminal. Look for line starting with echo. – Nimesh Neema May 27 at 11:04

You must log in to answer this question.

Browse other questions tagged .