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 –
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.
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:
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.
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.
There are numerous command-line text editors to choose from. Here are a few of the most popular ones:
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:
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.