title: Bash Profile Setting not working for path - PS1
body: <p>I've written the following bash profile settings file:</p>
  
  <pre><code>BLACK="\[\033[0;30m\]"
  DARK_GRAY="\[\033[1;30m\]"
  LIGHT_GRAY="\[\033[0;37m\]"
  BLUE="\[\033[0;34m\]"
  LIGHT_BLUE="\[\033[1;34m\]"
  GREEN="\[\033[0;32m\]"
  LIGHT_GREEN="\[\033[1;32m\]"
  CYAN="\[\033[0;36m\]"
  LIGHT_CYAN="\[\033[1;36m\]"
  RED="\[\033[0;31m\]"
  LIGHT_RED="\[\033[1;31m\]"
  PURPLE="\[\033[0;35m\]"
  LIGHT_PURPLE="\[\033[1;35m\]"
  BROWN="\[\033[0;33m\]"
  YELLOW="\[\033[1;33m\]"
  WHITE="\[\033[1;37m\]"
  DEFAULT_COLOR="\[\033[00m\]"
  
  
  function prompt_command {
      # How many characters of the $PWD should be kept
      local pwd_length=23
      if [ $(echo -n $PWD | wc -c | tr -d " ") -gt $pwd_length ]
      then 
          newPWD="$(echo -n $PWD | sed -e "s/.*\(.\{$pwd_length\}\)/\1/")"
      else
          newPWD="$(echo -n $PWD)"
      fi
  }
  PROMPT_COMMAND=prompt_command;
  
  PS1="\`if [ \$? = 0 ];
  then
      echo -e '$PURPLE[\t] $LIGHT_CYAN\u$YELLOW@\h$WHITE: $newPWD $GREEN$ $DEFAULT_COLOR';
  else
      echo -e '$PURPLE[\t] $LIGHT_CYAN\u$YELLOW@\h$WHITE: $newPWD $RED$ $DEFAULT_COLOR';
  fi; \`"
  export PS1;
  </code></pre>
  
  <p>For some reason getting the newPWD is not working. It is present in the enviroment (I can print it with the echo), however it isn't added to the command lines prompt. There an empty string is added always. So a sample output is: </p>
  
  <pre><code>[11:54:09] ber@szak:  $
  </code></pre>
  
  <p>Any ideas why not?</p>
  
  <hr>
  
  <p>PS. Here it is my solution to this: </p>
  
  <pre><code>BLACK="\[\033[0;30m\]"
  DARK_GRAY="\[\033[1;30m\]"
  LIGHT_GRAY="\[\033[0;37m\]"
  BLUE="\[\033[0;34m\]"
  LIGHT_BLUE="\[\033[1;34m\]"
  GREEN="\[\033[0;32m\]"
  LIGHT_GREEN="\[\033[1;32m\]"
  CYAN="\[\033[0;36m\]"
  LIGHT_CYAN="\[\033[1;36m\]"
  RED="\[\033[0;31m\]"
  LIGHT_RED="\[\033[1;31m\]"
  PURPLE="\[\033[0;35m\]"
  LIGHT_PURPLE="\[\033[1;35m\]"
  BROWN="\[\033[0;33m\]"
  YELLOW="\[\033[1;33m\]"
  WHITE="\[\033[1;37m\]"
  DEFAULT_COLOR="\[\033[00m\]"
  
  export MYPATHPS='$(
      echo -n "${PWD/#$HOME/~}" | 
      awk -F "/" '"'"'{
          if (length() &gt; 14) {
              if (NF&gt;4) print  "/"  "/.../" $(NF-1) "/" $NF;
              else if (NF&gt;3) print  "/"  "/.../" $NF;
              else print  "/.../" $NF;
          }
          else print ;
      }'"'"'
  )';
  
  PS1="$PURPLE[\t] $LIGHT_CYAN\u$YELLOW@\h \` if [ \$? = 0 ]
      then
          echo -en '$GREEN'
      else
          echo -en '$RED'
      fi;
  \` $MYPATHPS $ $DEFAULT_COLOR ";
  export PS1;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ecys2.png" alt="enter image description here"></p>