Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active January 14, 2021 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zulhfreelancer/c7a214a57761ea1f2195a06bc6e3dd1a to your computer and use it in GitHub Desktop.
Save zulhfreelancer/c7a214a57761ea1f2195a06bc6e3dd1a to your computer and use it in GitHub Desktop.
How to prepend ZSH prompt with text and background color?

How to prepend ZSH prompt with text and background color?

Steps:

  1. Open your Oh My ZSH theme file i.e. $ nano ~/.oh-my-zsh/themes/maran.zsh-theme

  2. Add the following code in the PROMPT variable:

    %{$bg[yellow]%}%{$fg[red]%}YOUR_TEXT_HERE%{$reset_color%}
    

    Example of full PROMPT variable:

    PROMPT='%{$bg[yellow]%}%{$fg[red]%}POC%{$reset_color%} %{$fg[cyan]%}%n%{$reset_color%}@%{$fg[yellow]%}%M:%{$fg[green]%}%/%{$reset_color%}$(git_prompt_info) %(!.#.$) '
    
  3. Save and exit the editor

  4. Run $ source ~/.zshrc

  5. Done (you may need to logout and login again if it doesn't work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment