Skip to content

oc edit – How To Customize Your OpenShift / Kubernetes CLI Editor

Avatar photo

Introduction: The command line, a.k.a. the terminal, is a powerful tool for interacting with your computer, especially when working with tools like OpenShift (oc). One aspect of your command-line experience that you might not think much about is the text editor you use for tasks like editing configuration files or composing longer messages. In this blog post, we’ll explore how to set your preferred text editor for oc edit commands by customizing the EDITOR environment variable. We’ll explain what the oc command is, demystify the concept of shell configuration files, discuss the importance of the EDITOR variable, and suggest some common CLI editors.

Also note, that the process is the same for the Kubernetes CLI utility – kubectl.

What is the oc Command?

The oc command is a crucial tool for working with OpenShift, a container orchestration platform. It allows you to interact with your OpenShift cluster from the command line. You can create and manage applications, configure resources, monitor your cluster, and more. It’s a versatile tool that simplifies many administrative tasks.

Shell Configuration Files – What Are They?

Shells are the interfaces between you and your computer’s operating system, and they have configuration files that define how the shell behaves. Depending on the shell you use (e.g., Bash, Zsh, Fish), these configuration files go by different names:

  • Bash: ~/.bashrc
  • Zsh: ~/.zshrc
  • Fish: ~/.config/fish/

These files contain settings, aliases, and environment variables, and they are executed every time you start a new terminal session. Customizing them can greatly enhance your command-line experience.

The Importance of the EDITOR Environment Variable

The EDITOR environment variable is your key to customizing the text editor used by various command-line tools. When you run a command that requires text editing, like git commit or oc edit, the system checks the EDITOR variable to determine which editor to open. Setting this variable allows you to use your favourite text editor for these tasks.

Common CLI Editors

There are numerous command-line text editors to choose from. Here are a few of the most popular ones:

  1. Vim: Known for its steep learning curve but unmatched power and efficiency once you’ve mastered it.
  2. Nano: A simpler and more user-friendly text editor for basic editing tasks.
  3. Emacs: An extensible text editor that can be customized to suit a wide range of needs.
  4. Visual Studio Code (VSCode): The command-line version of the popular Visual Studio Code editor, known for its extensibility and features.
  5. Sublime Text: Offers a command-line interface and is well-regarded for its elegant and intuitive design.

Setting Your Preferred Editor

To set your preferred editor (let’s say, Vim) as the default for oc edit and other commands, you need to edit your shell configuration file (e.g., ~/.bashrc) and add the following line:


export EDITOR=vim

Replace vim with the path to your preferred editor if it’s not installed in a standard location.

Customizing your command-line editing experience might seem like a small thing, but it can greatly enhance your productivity and comfort when working in the terminal. Setting the EDITOR environment variable is a simple way to make your command-line tools work the way you want them to, and you can choose from a variety of editors to suit your preferences. Whether you’re a Vim enthusiast or a fan of simpler editors like Nano, your command line, your rules!


The views expressed and the content shared in all published articles on this website are solely those of the respective authors, and they do not necessarily reflect the views of the author’s employer or the techbeatly platform. We strive to ensure the accuracy and validity of the content published on our website. However, we cannot guarantee the absolute correctness or completeness of the information provided. It is the responsibility of the readers and users of this website to verify the accuracy and appropriateness of any information or opinions expressed within the articles. If you come across any content that you believe to be incorrect or invalid, please contact us immediately so that we can address the issue promptly.

Avatar photo
Gineesh Madapparambath is the founder of techbeatly and he is the author of the book - 𝗔𝗻𝘀𝗶𝗯𝗹𝗲 𝗳𝗼𝗿 𝗥𝗲𝗮𝗹-𝗟𝗶𝗳𝗲 𝗔𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗼𝗻. He has worked as a Systems Engineer, Automation Specialist, and content author. His primary focus is on Ansible Automation, Containerisation (OpenShift & Kubernetes), and Infrastructure as Code (Terraform). (aka Gini Gangadharan -


1 Response

  1. […] Think of it as a scalpel – powerful for quick fixes, but one wrong move can cause chaos! You can configure your preferred editor for kubectl if […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.