Reputation: 193
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.
Upvotes: 0
Views: 1499
Reputation: 193
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\]\$
Upvotes: 0
Reputation: 2093
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.
Upvotes: 2