Skip to content

Instantly share code, notes, and snippets.

@Genki-S
Created January 29, 2015 12:59
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 Genki-S/60d4d6585b8253dde6fe to your computer and use it in GitHub Desktop.
Save Genki-S/60d4d6585b8253dde6fe to your computer and use it in GitHub Desktop.
(let ((physmem (car (split-string (shell-command-to-string "top -l 1 | head -n 10 | grep PhysMem") "\n")))
(mem-used nil)
(mem-unused nil))
(save-match-data (and (string-match "PhysMem: \\([0-9]+[MG]\\) used (\\([0-9]+[MG]\\) wired), \\([0-9]+[MG]\\) unused." physmem)
(setq mem-used (match-string 1 physmem)
mem-unused (match-string 3 physmem))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment