Right now every command which starts with a space character gets ignored by bash history (HISTCONTROL=ignoreboth
in ~/.bashrc
).
I would like to have a better visual cue when I press space as the first character in the prompt input field.
So is there a method of adding such a thing in the bash prompt?
For example, you would color a part of the prompt when it notices that you press space as the first character of the input field (because obviously reacting to other space characters in the input field would be silly).
Best Answer
So, admittedly, this is a little hackish but I think it will accomplish your end goal (even if it's not in the way you wanted). In your
.bashrc
(or anywhere else that gets sourced on login) add something similar to the following.Every time the space bar is pressed it will call the
check_space
function to see whether it should print out a warning or not.Thanks to help from Jeff here who got help from Dmitry here
EDIT FOR dlsso:
To use an arbitrary char instead of space: