I'd like to mess with my Bash prompt, but I'd like to do so in a way that doesn't corrupt my already extant one. I could just comment it out, but is there a way to test it either with an online tool or a CLI tool?
3 Answers
You could create a file with your "new prompt" tweaks and then source it from the command line.
vim new_prompt.bash source ./new_prompt.bash The new prompt will only be active in that shell. If you open a new shell, your old prompt will be sourced and set.
When you are ready to 'commit' the new prompt, just add it to your bash initialization scripts.
EDIT:
I also just found this online bash prompt preview. I don't know what version of bash it's based on.
In VIM, CTRL+Z will bring you back to the terminal while keeping Vim open in the background. From there like others mentioned you can write source ~/.bashrc and it will reload your file and update your prompt. To return to your .bashrc file, simply type fg in terminal. It will bring vim back to your foreground. This has the advantage that you dont need to close vim, and you can undo your changes, but you do need to write your changes if you want to test it out.
8 years later but I hope this helps somebody.
You could change PS1 and others to a different value, if you don't like it don't add it to your .bashrc
bashwhen not on a Unix machine. Is that your goal (a web-basedbash)?shand test your new PS1 there. Puh, that was hard.