Skip to content

Instantly share code, notes, and snippets.

@lmlsna
Last active February 6, 2022 23:37
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 lmlsna/67be9d0186ae4b354fcaf5de44d96555 to your computer and use it in GitHub Desktop.
Save lmlsna/67be9d0186ae4b354fcaf5de44d96555 to your computer and use it in GitHub Desktop.
Source BASH one liner to change prompt color
#!/bin/bash
#
# Source this file with an to change the current prompt color
# No arguments for normal (green) and red (root) defaults
# Include an integer 0 - 255 after for an x256term color prompt
#
# You can also paste into .bashrc with $1 replace with an integer or variable
#
# Examples:
#
# source ./ps1_color
# source ./ps1_color 222
[[ $(( 255-${1-34} )) -ge 0 ]] && export PS1="\[\033[38;5;${1-34}m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ ";
#!/bin/bash
#
# bashrc example to give random prompt color
prompt_color=$(shuf -n 1 -i 1-255)
export PS1="\[\033[38;5;${prompt_color}m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$ ";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment