How to hide and show option in Atom Context Menu


Hello I am wondering what is the best method for showing and hide one single option in the context menu.

I see there is a shouldDisplay(event)
(Optional) A Function that is called to determine whether to display this item on a given context menu deployment.

I am unsure how to approach this problem. Any examples of how to use the shouldDisplay(event)???


The shouldDisplay property should be a function that returns true or false based on some calculation.

For example if you want to only show an item in the context menu in the morning you could write

  "atom-text-editor": [
      label: "Good Morning­čî×",
      shouldDisplay: function(event) {
        return (new Date().getHours() < 12);

The event parameter will have more information about the right click event like the x,y coordinate and whether they were holding down any special keys at the time that they clicked.