Skip to content

Instantly share code, notes, and snippets.

@ahosker
Last active July 30, 2026 15:53
Show Gist options
  • Select an option

  • Save ahosker/267f375a65378bcb9a867fd9a195db1e to your computer and use it in GitHub Desktop.

Select an option

Save ahosker/267f375a65378bcb9a867fd9a195db1e to your computer and use it in GitHub Desktop.
OpenCode Plugins: Terminal Bell

.env Protection

A simple OpenCode Plugin to block access to .env files.

How to Install?

On Linux, save env-protection.ts to ~/.config/opencode/plugin/env-protection.ts.

env-protection.ts

import type { Plugin } from "@opencode-ai/plugin"

export const EnvProtection = async ({ client, $ }) => {
  return {
    tool: {
      execute: {
        before: async (input, output) => {
          if (input.tool === "read" && output.args.filePath.includes(".env")) {
            throw new Error("Do not read .env files");
          }
        },
      },
    },
  };
};

Credit

lkhari

dkarter ~Advanced Version

Terminal Bell

A simple OpenCode plugin to ring the terminal bell once a request is complete.

How to Install?

On Linux, save terminal-bell.ts to ~/.config/opencode/plugin/terminal-bell.ts.

terminal-bell.ts

import type { Plugin } from "@opencode-ai/plugin"

export const TerminalBell: Plugin = async ({ project, client, $, directory, worktree }) => {
  return {
    event: async ({ event }) => {
      if (event.type === "session.idle") {
        console.log("Session went idle")
        await Bun.write(Bun.stdout, "\x07")
      }
    }
  }
}

VS Code

If you are using VSCode & SSH, you need to enable terminalBell in the settings, in a project that will be .vscode/settings.json the settings file can be as simple as:

{
    "accessibility.signals.terminalBell": {
        "sound": "on",
        "announcement": "auto",
    }
}

Credit

CarlosGtrz

@Tenrys

Tenrys commented Mar 5, 2026

Copy link
Copy Markdown

The terminal bell plugin is great, but the "session.idle" event seems to fire for subagents too, it's quite annoying...

@thaumkid

thaumkid commented May 2, 2026

Copy link
Copy Markdown

I made a heavy-duty version of this here for Mac users. I looked at the above comments and tried to make it super user-configurable. Subagent firing is suppressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment