2

This question already has an answer here:

my environment

Is it possible to make bash run clear && ls -A --color whenever I hit enter on an empty line?

I don't know it that's relevant, but I'm using set -o vi for vi mode.

marked as duplicate by G-Man Says 'Reinstate Monica', Jeff Schaller, LinuxSecurityFreak, Anthony G - justice for Monica, Satō Katsura May 8 '18 at 15:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

This is possible by setting your PROMPT_COMMAND as such.

PROMPT_COMMAND='h=$(fc -l -1); h=${h%% *}; (( h != oh )) || { clear && ls -A --color; }; oh=$h'
  • 1
    Doesn't work. You need to add parenthesis around clear && ls -A --color – Chris May 8 '18 at 3:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.