This command line tool helps you change the appearance of your command line prompt and store your favorite formats to use them at any time.
. prompt-formatter <command> [options]
set <format>
: Set the prompt to the given format.store
: Store the current format.set-default [<index>]
: Set the the preferred default format to the current or the specified format.load <index>
: Set the prompt to the saved format at the given index.reset
: Set the prompt to a standard format.default
: Set the prompt to the preferred default format.random
: Set the prompt to a random format.view <index>
: Print the stored format at the given index.ls (or list)
: List all of the stored formats.del (or delete) <index>
: Delete the stored format at the given index.help (-h or --help)
: Display the help message.
-
Clone this repository to your local machine.
-
Navigate to the repository's directory:
cd /path/to/prompt-formatter
-
Make the script executable:
chmod x prompt-formatter
-
Use the script as described in the Usage section above.
The set
command allows you to customize your prompt format by specifying various options. You can format your prompt string by using color options and additional options to display user information, the current working directory, time, date, and more.
The script supports the following colors that you can use in your prompt format:
black
orange
cyan
lightRed
lightBlue
white
red
blue
lightGray
lightGreen
lightPurple
reset
(which resets the color to the default)
To use color options, simply include them in your format string using a -
followed by the color name.
. prompt-formatter set -blue '$' -green '>' -reset
You can also include various other options in your prompt format:
u
: Display the user name.h
: Display the hostname.w
: Display the path to the working directory.W
: Display the working directory name.t
: Display the time.d
: Display the date.n
: Add a newline.s
: Add a space.
To use these options, include them in your format string using a -
followed by the option. You can combine multiple options in your format string as needed.
. prompt-formatter set -green -u @ -h / -W : -s -orange
Experiment with different color and option combinations to create a custom prompt format that suits your preferences.
Don't forget to use
prompt-formatter store
to save the format you set.
To make it even easier to use the "prompt-formatter" tool, you can add an alias to your .bashrc
file.
-
Open your
.bashrc
file using a text editor:nano ~/.bashrc
-
Add the following line at the end of the file:
alias custom-prompt='. path/to/prompt-formatter'
Replace
path/to/prompt-formatter
with the actual path to the "prompt-formatter" script on your system. -
To apply the changes immediately, either run the following command or restart your terminal:
source ~/.bashrc
Now you can use the "prompt-formatter" tool by simply typing custom-prompt
in your terminal.
You can configure your custom-prompt
alias to automatically load your preferred format when your terminal starts by adding an option to your .bashrc
file.
To load the default format automatically, add the following line to your .bashrc
file:
custom-prompt default
If you want to load a random format from the stored formats each time you start your terminal, add the following line to your .bashrc
file:
custom-prompt random
Remember to make sure that the custom-prompt
alias is defined as explained in the Adding an Alias section above.
After making these changes and saving the file, the specified format will be applied automatically when you start a new terminal session.