Forge Home

colorprompt

Adds colors to the user and host portions of the PS1 prompt.

8,235 downloads

6,958 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 3.0.2 (latest)
  • 3.0.1
  • 3.0.0
released Oct 31st 2018
This version is compatible with:
  • Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >=4.0.0 < 6.0.0
  • RedHat, CentOS, OracleLinux, Fedora, Debian, Ubuntu

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'jmarion-colorprompt', '3.0.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add jmarion-colorprompt
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install jmarion-colorprompt --version 3.0.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

jmarion/colorprompt — version 3.0.2 Oct 31st 2018

Puppet Color Prompt

Overview

This module adds colors to the user and host portions of the PS1 prompt.

Module Description

This module adds a script to /etc/profile.d to insert terminal colors into your PS1 prompt variable. This is useful to help differentiate production system prompts from local prompts.

You haven't lived until you've accidentally shut down a production system! ;)

Usage

Basic Usage

This will install the colorprompt script with the default settings. This will only color the user portion of the prompt when you are root.

include ::colorprompt

Production System in Red

This is what you might define for a production system that should show a red hostname and prepend a red 'PRD' to your prompt:

class { '::colorprompt':
  env_name   => 'PRD',
  env_color  => 'red',
  host_color => 'red',
}

Available Colors

This module supports the basic colors of an 8-color terminal, which should be pretty universally supported:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

All of these are also available as background colors by adding 'bg_' to the beginning of the color name, eg bg_yellow.

A few styles are also supported:

  • bright
  • faint
  • underline
  • blink

Combining Colors

You can combine multiple colors and styles by defining an array instead of just a string. For example, this monstrosity:

class { '::colorprompt':
  env_name  => 'ATROCIOUS',
  env_color => [ 'underline', 'green', 'bg_red' ],
}

Reference

Classes

  • colorprompt: Creates the script in /etc/profile.d/

Parameters

ensure

Control if this module's functionality is active.
Type: String
Default: 'present'

path

Path to the colorprompt script.
Type: String
Default: '/etc/profile.d/colorprompt.sh'

default_usercolor

Sets a color for all users. Specific user colors can be overridden by custom_usercolors.
Type: String or Array
Default: undef

custom_usercolors

Sets the color for specific users.
Type: Hash
Default: { 'root' => 'red' }

host_color

Which color to use for the host portion of the prompt.
Type: String or Array
Default: undef

env_name

The string added to the beginning of the prompt, 'DEV', 'PROD', etc.
Type: String
Default: undef

env_color

Color of the string added to the beginning of the prompt, see 'env_name'.
Type: String or Array
Default: undef

prompt

Format of the $PS1 variable. Use ${env}, ${userColor} and ${hostColor}.
Type: String
Default:
${env}[${userColor}\u\[\e[0m\]@${hostColor}\h\[\e[0m\] \w]\\\\$ on RedHat
${env}${debian_chroot:+($debian_chroot)}${userColor}\u\[\e[0m\]@${hostColor}\h\[\e[0m\]:\w\\\\$ on Debian

modify_skel

Comments out PS1 variables in /etc/skel/.bashrc on Debian distributions.
Type: Boolean
Default: true on Debian, false on RedHat

modify_root

Comments out PS1 variables in /root/.bashrc on Debian distributions.
Type: Boolean
Default: true on Debian, false on RedHat

Authors

Copyright 2014-2015 Gjermund Jensvoll <gjerjens@gmail.com>
Copyright 2018 John Marion <jmarion-ext@arista.com>

Limitations

Ubuntu and Debian need modification to existing user ~/.bashrc files (comment out PS1 variables).