0

I am trying to change my ps1 command prompt to print out the contents of pwd and also the result of the du command. I have tried adding this to my PS1 variable in my .bashrc file

PS1='\[\033[01;32m\]\w\$(du -s `echo $PWD` 2>/dev/null | awk '{printf $1}')\[\033[00m\]\$ '

after running source ~/.baashrc I was expecting an output of something like:

/home/some_user/ XXXX (the number returned from du) $ 

but instead I recieve

})\[\033[00m\]\$ : command not found

any help is greatly appreciated.

Jay Wehrman
  • 193
  • 2
  • 10

2 Answers2

2

Try something like

export PS1='[$(ls $PWD ; du -sh /home/me)]'

However, it must be said that this will put an overhead on your system/filesystem. Just bear that in mind.

tomgalpin
  • 1,943
  • 1
  • 4
  • 12
0

my solution:

I made a custom function with the du command and then just added that into the PS1 variable like so:

function printDu {
    du -s echo $PWD 2>/dev/null | awk '{printf $1}'
}
PS1 = '\[\033[01;32m\]\w\`printDu`\[\033[00m\]\$
Jay Wehrman
  • 193
  • 2
  • 10