Skip to content

Instantly share code, notes, and snippets.

@atomicules
Created September 2, 2011 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomicules/1190099 to your computer and use it in GitHub Desktop.
Save atomicules/1190099 to your computer and use it in GitHub Desktop.
Extracts/examples from my .vimrc to make settings conditionally based on OS and network
"IP Address specific
"-------------------
"(i.e. Home or Work)
if ip == -1
"Set proxies, Python urllib2 (TwitVim, Simplenote.vim) will automatically pick
"these up
let $http_proxy = 'http://<username>:<password>@<proxy-url>:<proxy-port>'
let $https_proxy = 'http://<username>:<password>@<proxy-url>:<proxy-port>'
endif
"OS Specific
"-----------
let os = substitute(system('uname'), "\n", "" ,"") "thanks to http://objectmix.com/editors/149466-operating-system-checking-vimrc-files.html#post517594
if os == "Linux"
...
let ip = match(system('ip addr show'), "10.0.1")
elseif os == "Darwin"
...
let ip = match(system('ipconfig getifaddr en1'), "10.0.1") "Or whichever enX interface you need
else "Assume windows as uname doesn't work on Windows
...
let ip = match(system('ipconfig'), "10.0.1")
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment