Python script to generates bash PS1 prompts using template blocks
prompt_maker [-h] "<string>"
Where <string>
refers to any combination of the predefined [colors]
and [special]
blocks (enclosed in square brackets), along with any regular characters, including other special characters that bash recognises but aren't listed below.
colors: special:
[black] [username]
[red] [hostshort]
[green] [hostfull]
[yellow] [dirshort]
[blue] [dirfull]
[purple] [newline]
[cyan] [date]
[white] [time24]
[bblack] [time12]
[bred] [tty]
[bgreen] [jobs]
[byellow] [rbracket]
[bblue] [lbracket]
[bpurple] [dollar]
[bcyan]
[bwhite]
[nocolor]
[bcolors]
are bold colors. [lbracket]
and [rbracket]
can be used to insert literal [
and ]
respectively.
prompt_maker "[red][username]@[hostshort]:[bgreen][dirfull][nocolor][dollar]"
becomes
PS1='\[\e[0;31m\]\u@\h:\[\e[1;32m\]\w\[\e[m\]\$ \[\e[m\]'