Last active
February 6, 2022 23:37
-
-
Save lmlsna/67be9d0186ae4b354fcaf5de44d96555 to your computer and use it in GitHub Desktop.
Source BASH one liner to change prompt color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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\]$ "; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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