Shell prompt segments in Go

0a6019d Add seg cwd-count

~fmac pushed to ~fmac/corylus git

5 days ago

692061b Change output example

~fmac pushed to ~fmac/corylus git

5 days ago


Simple shell prompt generator in Go.


Corylus expects strings as arguments.

If an argument matches the name of a known segment generator, then the result will be appended.

If an argument does not match any generator then it is appended as string.

Edit the prompt variable in your shell configuration file, probably .bashrc, .zshrc or .profile.

For ZSH you may need to enable the prompt expansion by adding setopt PROMPT_SUBST to your .zshrc.

At the moment the available segments are:

  • cwd
  • cwd-count
  • hostname
  • tail
  • username

Here is an example with some colors.

PS1='$(corylus \
	"[" hostname "] " \
	"\033[34m" username "\033[0m " \
	"\033[35m" cwd "\033[0m" " " \
	"[" cwd-count " files]" \

Which outputs with this format:

[maze] fmac ~/r/c/.git [13 files]


go get git.sr.ht/~fmac/corylus


Of course you are free to send me a git-email with a patch that adds new segments.