LinuxCommandLibrary

opencode

Open code files

TLDR

Start the interactive TUI

$ opencode
copy

Run opencode in non-interactive mode by passing a prompt directly
$ opencode run "[message]"
copy

Use a specific model and agent
$ opencode run [[-m|--model]] [provider]/[model] --agent [agent_name] "[message]"
copy

List all available models from configured providers
$ opencode models
copy

Manage credentials and login for providers
$ opencode auth login
copy

Start a headless opencode server for API access
$ opencode serve [[-h|--hostname]] [hostname] [[-p|--port]] [port]
copy

Manage AI assistant agents for OpenCode
$ opencode agent [command]
copy

Create a new agent with custom configuration
$ opencode agent create
copy

SYNOPSIS

opencode [OPTIONS] [PATH...]

PARAMETERS

-h, --help
    Display help information about the command.

-v, --version
    Show version information of the underlying editor or script.

-n, --new-window
    Force opening a new editor window, even if another window is already open.

-r, --reuse-window
    Force opening in the last active editor window, if available.

-d, --diff <file1> <file2>
    Open two files in the editor's diff view to compare their contents.

-g, --goto <file>:<line>[:<column>]
    Open a file at a specific line and optionally a column number.

--wait
    Wait for the opened files or editor process to be closed before returning control to the terminal.

--add <path>
    Add files or folders to the current or last active editor window workspace.

DESCRIPTION

opencode is a conceptual command designed to quickly open files, directories, or entire projects within a designated code editor from the command line. While not a standard Linux utility, it encapsulates the common action of launching an editor to work on source code.

It allows users to specify paths to files or directories, and often supports options for new windows, diff views, or specific line numbers, streamlining the development workflow by integrating the terminal with the editor. This utility is typically a custom alias or script, or refers to the command-line interface of a popular editor like Visual Studio Code's code command. Its primary purpose is to enhance productivity by providing a rapid way to access and modify code directly from the terminal prompt, eliminating the need to manually navigate through a graphical interface to open project files.

CAVEATS

Disclaimer: The command opencode is not a standard Linux utility found in most distributions. This analysis is based on the common functionality associated with 'open code' commands, such as the code command-line interface for Visual Studio Code, or similar custom scripts/aliases. Users should verify if such a command exists on their system or if it refers to a specific application's CLI tool.

INSTALLATION

Because opencode is not a standard command, it typically needs to be installed as part of a specific code editor (e.g., installing Visual Studio Code provides the code command) or custom-scripted by the user. Users may create an alias or a shell function named opencode that calls their preferred editor or a script that intelligently decides which editor to launch based on environment variables or file associations.

CONFIGURATION

Users can configure which editor opencode (if it were a custom script) should launch. This often involves setting environment variables like EDITOR or VISUAL in their shell's configuration file (e.g., .bashrc, .zshrc), or directly modifying the custom script itself. For application-specific CLIs (like code for VS Code), configuration is usually done within the editor's settings.

HISTORY

As opencode is not a standard command, it does not have a formal history. However, the concept of launching a code editor from the command line is as old as terminal-based editors like Vi and Emacs. Modern graphical editors, especially those designed for development, often provide a command-line utility (e.g., code for Visual Studio Code, subl for Sublime Text, atom for Atom) to integrate seamlessly with the terminal, allowing developers to quickly open projects or files in their preferred GUI editor directly from a directory in the terminal. The exact implementation and name (opencode) would depend on specific user configurations or bespoke software.

SEE ALSO

code(1), xdg-open(1), gnome-open(1), kde-open(1), vi(1), emacs(1), nano(1)

Copied to clipboard