Domanda

Currently it is displayed as follows

export PS1='${white}[\t] ${blue}\W:${red}$(__git_ps1)${white} \$ '

enter image description here

I'd like to experiment with the same set up, but time displayed in the right most corner.

How can i modify my PS1 export for this to happen please?

È stato utile?

Soluzione

Don't think there's any way to right justify items on the prompt using PS1 in bash (pretty sure there's easy ways to do this in zsh though). You can try writing a function for the PROMPT_COMMAND environment variable and have it print the time with right justify, something along the lines of:

print_pre_prompt ()
{
    TIME=`date +%H:%M`
    printf "\e[1;37m%$(($COLUMNS))s" "${TIME}"
}
PROMPT_COMMAND=print_pre_prompt

Here, the \e[1;37m is the "white" color.

Altri suggerimenti

Is this your output prompt looking for ?

export PS1="\u@\w [\$(date +%k:%M:%S)]> "

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top