How to tell if the current operating system is OpenBSD in NeoVim?

634 Views Asked by At

I use NeoVim on two machines, one running OpenBSD and another running Linux. I want to be able to run/load certain commands if I'm on the OpenBSD machine. How can I do this? I've tried the following but it doesn't seem to work.

if vim.fn.has('openbsd') then
  ... do stuff ...
end
1

There are 1 best solutions below

0
lcheylus On BEST ANSWER

With Neovim, you can use Vim functions to get OS name :

vim.loop.os_uname().sysname
  • On Linux, function returns Linux
  • On OpenBSD, function returns OpenBSD