mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Detect If You Are On A Mac as a vim til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||||
|
|
||||||
_548 TILs and counting..._
|
_549 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -561,6 +561,7 @@ _548 TILs and counting..._
|
|||||||
- [Delete To The End Of The Line](vim/delete-to-the-end-of-the-line.md)
|
- [Delete To The End Of The Line](vim/delete-to-the-end-of-the-line.md)
|
||||||
- [Deleting Buffers In BufExplorer](vim/deleting-buffers-in-bufexplorer.md)
|
- [Deleting Buffers In BufExplorer](vim/deleting-buffers-in-bufexplorer.md)
|
||||||
- [Deleting Directories Of Files From netrw](vim/deleting-directories-of-files-from-netrw.md)
|
- [Deleting Directories Of Files From netrw](vim/deleting-directories-of-files-from-netrw.md)
|
||||||
|
- [Detect If You Are On A Mac](vim/detect-if-you-are-on-a-mac.md)
|
||||||
- [Difference Between :wq and :x](vim/difference-between-wq-and-x.md)
|
- [Difference Between :wq and :x](vim/difference-between-wq-and-x.md)
|
||||||
- [Display Word Count Stats](vim/display-word-count-stats.md)
|
- [Display Word Count Stats](vim/display-word-count-stats.md)
|
||||||
- [Edges Of The Selection](vim/edges-of-the-selection.md)
|
- [Edges Of The Selection](vim/edges-of-the-selection.md)
|
||||||
|
|||||||
24
vim/detect-if-you-are-on-a-mac.md
Normal file
24
vim/detect-if-you-are-on-a-mac.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Detect If You Are On A Mac
|
||||||
|
|
||||||
|
There are a couple ways of detecting with vimscript if you are on a mac.
|
||||||
|
This can be useful if you are writing a plugin with OS-specific
|
||||||
|
functionality. Here are two ways to make that check.
|
||||||
|
|
||||||
|
```vimscript
|
||||||
|
if has('macunix') || has('mac') || has('osx')
|
||||||
|
...
|
||||||
|
endif
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can use Vim's `system()` function to execute unix's
|
||||||
|
`uname` command. This command will give you the name of the operating
|
||||||
|
system. In the event you are using a Mac, the result of `uname` should be
|
||||||
|
`Darwin`. The following regex match is a good way to make this check.
|
||||||
|
|
||||||
|
```vimscript
|
||||||
|
if system('uname') =~ "Darwin"
|
||||||
|
...
|
||||||
|
endif
|
||||||
|
```
|
||||||
|
|
||||||
|
See `:h has()`, `:h system()`, and `man uname` for more details.
|
||||||
Reference in New Issue
Block a user