1

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)

2 Answers 2

2

Does has("macunix") do what you're looking for? You can take a look at :help has and :help feature-list for other options.

1
  • 1
    I prefer has("mac")
    – juanpablo
    Sep 23, 2011 at 18:43
2

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')

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .