Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Can you please explain what the role of cb4 is? Is it a built-in name or something you came up with, what does it do, is it something like a “scoped” configuration/named session? Thanks Commented Nov 2, 2022 at 14:27
  • 1
    @DavidWolf The hook is called preexec, I called my function cb4, call it whatever you want. You are calling a method that calls the hook which runs clear after every command you run (making your command at the top of your terminal window which I wanted at the time for something specific, your usage may vary). But if you open a new terminal then that will not clear automatically, that would require running the command cb4 again. That is intentional, so you only call cb4 once when you know after every command following it you want that behavior. Commented Nov 8, 2022 at 4:15
  • As an alternative to the currently accepted answer which if you had in your .zshrc or similar would run all the time which you might not actually want. Commented Nov 8, 2022 at 4:16
  • Wonderful. By calling the function the hook is registered, now I understand – thanks a lot @jasonleonhard Commented Nov 8, 2022 at 8:28
  • You are welcome. I am glad to be of service. Commented Nov 8, 2022 at 21:11