File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
10
10
For a steady stream of TILs from a variety of rocketeers, checkout
11
11
[ til.hashrocket.com] ( https://til.hashrocket.com/ ) .
12
12
13
- _ 548 TILs and counting..._
13
+ _ 549 TILs and counting..._
14
14
15
15
---
16
16
@@ -561,6 +561,7 @@ _548 TILs and counting..._
561
561
- [ Delete To The End Of The Line] ( vim/delete-to-the-end-of-the-line.md )
562
562
- [ Deleting Buffers In BufExplorer] ( vim/deleting-buffers-in-bufexplorer.md )
563
563
- [ Deleting Directories Of Files From netrw] ( vim/deleting-directories-of-files-from-netrw.md )
564
+ - [ Detect If You Are On A Mac] ( vim/detect-if-you-are-on-a-mac.md )
564
565
- [ Difference Between : wq and : x ] ( vim/difference-between-wq-and-x.md )
565
566
- [ Display Word Count Stats] ( vim/display-word-count-stats.md )
566
567
- [ Edges Of The Selection] ( vim/edges-of-the-selection.md )
Original file line number Diff line number Diff line change
1
+ # Detect If You Are On A Mac
2
+
3
+ There are a couple ways of detecting with vimscript if you are on a mac.
4
+ This can be useful if you are writing a plugin with OS-specific
5
+ functionality. Here are two ways to make that check.
6
+
7
+ ``` vimscript
8
+ if has('macunix') || has('mac') || has('osx')
9
+ ...
10
+ endif
11
+ ```
12
+
13
+ Alternatively, you can use Vim's ` system() ` function to execute unix's
14
+ ` uname ` command. This command will give you the name of the operating
15
+ system. In the event you are using a Mac, the result of ` uname ` should be
16
+ ` Darwin ` . The following regex match is a good way to make this check.
17
+
18
+ ``` vimscript
19
+ if system('uname') =~ "Darwin"
20
+ ...
21
+ endif
22
+ ```
23
+
24
+ See ` :h has() ` , ` :h system() ` , and ` man uname ` for more details.
You can’t perform that action at this time.
0 commit comments