Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Tiny problem with a prompt



I am trying to display current directory in different colour based on if
it's writeable or not. What I thought will be simple  if...then...else
task has become a really headache. My (simplistic) code is as follows:


prompt_k2_setup() {
    
    pdir() {
        if [[ -w $PWD ]]; then
            dirp='%3F%1/%3f '
        else
            dirp='%1F%1/%1f '
        fi  
    }   
    
    precmd() { pdir }

    PS1="${dirp} "
}   

prompt_k2_setup "$@"


It sort off works, but not as I intended it to - for the prompt to show
current directory I need to execute  'prompt k2'  each time I change to
different directory.

I am probably missing something painfully obvious but I can't figure it
out. A nudge in the right direction will be greatly appreciated.



Messages sorted by: Reverse Date, Date, Thread, Author