Customize your Zsh/Bash terminal prompt with a menu-style selection guide. Choose what info you want the prompt to display (username, hostname, symbols, etc.) and customize their foreground and background colors—all from the command line. Use brighter colors for extra pop!
URL="https://github.com/kyletimmermans/shell-color-prompt-tool/releases/download/latest"; curl -q -s -S -LJO "$URL/shell-color-prompt-tool.sh" && chmod a+x shell-color-prompt-tool.sh && sudo mv shell-color-prompt-tool.sh /usr/local/bin/scpt && curl -q -s -S -LJO "$URL/scpt.1" && sudo mv scpt.1 /usr/local/share/man/man1/
curl -q -s -S -LJO "https://github.com/kyletimmermans/shell-color-prompt-tool/releases/download/latest/shell-color-prompt-tool.sh" && chmod +x shell-color-prompt-tool.sh
sudo apt install -y gawk
brew install gawk gnu-sed
sudo port install gawk gsed
-u, --usage, -h, --help Show usage/help menu
-v, --version Get program version. Reveal if a newer version is available on
GitHub
--uninstall Undoes the "Install as a Command" installation option. It will
delete /usr/local/bin/scpt (program) and the associated
man page
--comment-out Comment out older prompt lines in .zshrc / .bashrc
e.g. PROMPT= / PS1= to help prevent conflicting prompt
definitions
--omz Disables your 'Oh My Zsh' theme if you have one, which could
get in the way of applying your new prompt
--light-mode Better color contrast for the color picker menu and other
various portions on white/light-colored terminal backgrounds.
If you plan on using this flag, always put it first, before
all other flags/args
--no-extras Don't automatically add a newline to the start of the prompt
and a space to the end of the prompt
--separate-file Place the prompt string in a separate file instead of putting
it in .zshrc / .bashrc for any reason
E.g. --separate-file="~/test.txt"
--no-watermarks Don't add the "# Added by Shell-Color-Prompt-Tool" comment to
.zshrc / .bashrc when adding the prompt string and don't add the
"# Commented out by Shell-Color-Prompt-Tool" comment when
using --comment-out or --omz
--char-table Display a table of cool UTF-8 characters for copy-and-pasting
into prompt part choices. If you can't see the characters or
if they show up incorrectly, ensure that your terminal supports
the UTF-8 charset
Note
-
You don't need to add a newline character at the beginning of your prompt for spacing between actual prompts, one will be added for you. Same with a space after the prompt so there's space between the prompt and inputted commands, one will automatically be added for you. This feature can be disabled with the --no-extras flag
-
Colors may vary from system to system. When using the Custom RGB option, make sure your terminal supports TRUECOLOR (See here)
Don't like the prompt that got saved and want to change it back to its default? |
---|
1. In your Terminal type: vi ~/.zshrc or vi ~/.bashrc |
2. Hit 'i' on your keyboard to start editing the file and remove the line(s) at the bottom of the file, e.g. "export PROMPT=etc" (Zsh) or "export PS1=etc" (Bash), that has the comment above it: "# Added by Shell-Color-Prompt-Tool" |
3. If you used --comment-out or --omz, uncomment your old prompt lines where the line above it says: "# Commented out by Shell-Color-Prompt-Tool" |
4. Hit 'escape (esc)' on your keyboard and then type :wq and hit enter |
5. Back in your Terminal now, type source ~/.zshrc or source ~/.bashrc and hit enter |
6. Restart your Terminal |
7. Good as new! |
Caution
Exercise caution when copy and pasting code from someone else and/or code that you do not understand, into any of the parts option picker. Which includes, but is not limited to, the "Custom Datetime", "Other Zsh/Bash Prompt Expansion Variable", and "Other Environment Variable" choices.
Shell prompts are fully capable of running commands and entire command pipelines.
Bad code can break your host (e.g. rm -rf something), and malicious code (e.g. reverse shell), can harm your host.
graph TD;
CST(Choose Shell Type)-- Zsh --->ZSH(Choose Prompt Type: $PROMPT, $RPROMPT, or Both)
ZSH-->CHP(Choose Parts #40;Variables, Symbols, etc.#41;)
CST-- Bash ---CHP
CHP-->CSC(Choose Colors #40;Foreground and Background#41; for the Chosen Parts)
CSC-->Preview(Preview the Prompt Before Saving)
Preview-->Save(Save Prompt #40;Y/n#41;?)
style CST stroke:#e81416
style ZSH stroke:#ffa500
style CHP stroke:#faeb36
style CSC stroke:#79c314
style Preview stroke:#487de7
style Save stroke:#70369d
Need inspiration and ideas for cool prompts? Check out this list!
- https://github.com/ohmybash/oh-my-bash/wiki/Themes
- https://github.com/win0err/aphrodite-terminal-theme
I've seen a few programs, mainly web-based ones, that help you to build out and customize shell prompts. I wanted to make something that was native to the shell environment, no need to copy from the website and then needing to paste into your config on the command line. I wanted it to be all in one place. There's a few other features I wanted to see in a prompt customization program as well:
- Show the user all of the options they have for customizing their prompt, which includes all of the terminal variables (username, hostname, etc.) and many of the colors available
- Simple menu-style system for choosing which components and colors you'd like to be in the prompt
- No additional software required (besides for 2 flags, potentially) - Most Unix-based systems (Linux, macOS) already have Bash pre-installed, so there’s no need to install any additional interpreters or libraries
- No need to edit the .bashrc / .zshrc file at all, no need to copy and paste the variable in there. The program will put it in there for you
The plan is to potentially support other shells in the future. A big refactor would be needed to be able to support other ones. Right now Zsh and Bash are the main shells that are supported, but if you put in an issue or even submit a PR, I can work with you to add support for another shell.
A Bash shebang is used because it covers both Bash and Zsh users. Almost everyone that has Zsh, has Bash installed. However, not everyone that has Bash, has Zsh installed. Therefore, the Bash shebang covers all use cases. We can't use the "sh" shebang because that could invoke a shell that's not Bash or Zsh.
What themes like Powerlevel10k are doing to get the multiline RPROMPT effect, is using a print statement that runs every time, just before the PROMPT and RPROMPT are drawn. The extra line is not actually a part of the $RPROMPT variable, it just appears to be with some clever programming. romkatv, who created Powerlevel10k, has a code snippet here that explains how its done.
Nope! I realized too late after naming this project that .scpt files existed.