So I am on CH2, the instructor extracts a template to a file so they can use gedit to view. I thought "why not just use 'oc edit' (carefully exiting without saving) ... but it appears the editor (vi? vim?) does not do syntax highlighting (even when trying to toggle syntax). Is there some environment variable or something I can use to get syntax highlighting in oc edit ?
This is somewhat of a loaded question. The oc edit command will open the editor that is defailt for the environment. It is possible in various systems and based on user preferences that the editor could be vim, vim, or something else entirely.
If you have the editor specifed for VIM, then you would need VIM plugins for YAML files and other things so it would give you the formatting and syntax highlighting you might want to use.
It is also possible that if you are systems that have nicer GUIs to set editors to things like VSCode
set OC_EDITOR=code
So this question becomes two-fold ... one, you probably need to set the editor you want to use. Assuming that you set it to the editor of choice, you probably already have things setup for that editor for syntax highlighting and other things. If not, then you will need to setup the chosen editor with those pieces ... in the case of VSCode, you will need to download various extensions.
I'm not 100% sure for OCP syntax checking and stuff in general for OpenShift, but what I have shared with students for YAML (specifically for a lot of Ansible courses I teach) I use ...
https://www.arthurkoziel.com/setting-up-vim-for-yaml/
Since I teach both Ansible and OCP courses, I have just gotten used to some of this syntax highlighting for VIM. There are also tons of other things to consider with OCP like JINJA and JSON syntax highlighting too.
https://access.redhat.com/discussions/6987581
This discsussion might be useful as it refers to some JINA syntax highlighting plugins for VIM.
https://www.vim.org/scripts/script.php?script_id=1856
Some YAML ones
and finally some JSON for VIM
This is somewhat of a loaded question. The oc edit command will open the editor that is defailt for the environment. It is possible in various systems and based on user preferences that the editor could be vim, vim, or something else entirely.
If you have the editor specifed for VIM, then you would need VIM plugins for YAML files and other things so it would give you the formatting and syntax highlighting you might want to use.
It is also possible that if you are systems that have nicer GUIs to set editors to things like VSCode
set OC_EDITOR=code
So this question becomes two-fold ... one, you probably need to set the editor you want to use. Assuming that you set it to the editor of choice, you probably already have things setup for that editor for syntax highlighting and other things. If not, then you will need to setup the chosen editor with those pieces ... in the case of VSCode, you will need to download various extensions.
I'm not 100% sure for OCP syntax checking and stuff in general for OpenShift, but what I have shared with students for YAML (specifically for a lot of Ansible courses I teach) I use ...
https://www.arthurkoziel.com/setting-up-vim-for-yaml/
Since I teach both Ansible and OCP courses, I have just gotten used to some of this syntax highlighting for VIM. There are also tons of other things to consider with OCP like JINJA and JSON syntax highlighting too.
https://access.redhat.com/discussions/6987581
This discsussion might be useful as it refers to some JINA syntax highlighting plugins for VIM.
https://www.vim.org/scripts/script.php?script_id=1856
Some YAML ones
and finally some JSON for VIM
Also @MichaelQ - I haven't used it personally, but Red Hat has an OpenShift Toolkit extension for VSCode.
https://marketplace.visualstudio.com/items?itemName=redhat.vscode-openshift-connector
I heavily use the extension Red Hat provides for Ansible as I have VSCode on my personal machine, but I haven't bothered with the OCP Toolkit extension as most of our OCP courses don't have VSCode installed and accessible, so I've stuck to teaching and doing oc edit with VIM.
Thanks for the quick response Travis. I'm happy with vi and when I "vi something.yml" I get syntax highlighting just fine. So I tried
$ export OC_EDITOR=`which vi`
but still get some sort of vi editor without syntax highlighting when I "oc edit" a resource.
Sorry, I stand corrected. I just tested on the new environment and that no longer worked.
[student@workstation ~]$ export EDITOR=vim
.vimrc contents
autocmd FileType yaml setlocal ai ts=2 sw=2 et sts=2 cuc colorcolumn=3,5,7,9,11
So apparently with the newer one, the old alias I had no longer works. The above command does identify the YAML and provides the contents. I checked quickly with an Ansible YAML settings I have in VIMRC for Ansible courses.
If you are using one of our current workstations in the OCPv4.12 courses, this should work as I verified in the environment I'm using to teach the DO180 course this week.
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.