Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question
up vote 2 down vote accepted

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

share|improve this answer
I prefer has("mac") – juanpablo Sep 23 '11 at 18:43

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


: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')
share|improve this answer

You must log in to answer this question.

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