In vim with
:echo has('unix')
I can find out if the OS is Unix. How I can get more specific information about it? (Darwin, debian, etc)
Does has("macunix")
do what you're looking for? You can take a look at :help has
and :help feature-list
for other options.
Some of that information can be obtained from the uname
command, e.g.,
$ uname -a
The name of the distribution is often found in /etc/issue:
$ head -1 /etc/issue
You can use the Vim system() function to execute those commands and return their outputs, e.g.,
let os = system('uname -o')
let dist = system('head -1 /etc/issue')
See
:help system()
Note that the return value of the system() function includes the trailing newline, so you'll need to remove it or take it into account when testing the return values. One way to remove it is this:
let os = substitute(os, '\n', '', 'g')