0

I would like to add some logic to be executed each time I just press enter in the unix terminal, eg print hello:

sergei_rudenkov@ws18851:~$ 
Hello
sergei_rudenkov@ws18851:~$

I use ubuntu 14.04 and I found the way to print sting each time I launch new terminal, but I didn't find place to execute some logic each time the new command line appears.

Could you help me and is it possible at all?

Rudziankoŭ
  • 10,681
  • 20
  • 92
  • 192
  • Do you want to execute the code "each time you press enter" (eg, before running a command) or "each time the new [prompt] appears" (eg, after running a command)? – William Pursell Jan 21 '16 at 13:32

1 Answers1

4

The contents of PROMPT_COMMAND are executed just before each prompt is displayed.

$ PROMPT_COMMAND='echo hello'
hello
$
hello
$ echo foo
foo
hello
$
chepner
  • 497,756
  • 71
  • 530
  • 681