This repository has been archived by the owner on Dec 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
init-osx.el
95 lines (75 loc) · 3.16 KB
/
init-osx.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;; Mac hostnames have .local or similar appended
(setq system-name (car (split-string system-name "\\.")))
;; OS X ls doesn't support --dired
(setq dired-use-ls-dired nil)
;; Even though we may have set the Mac OS X Terminal's Alt key as the
;; emacs Meta key, we want to be able to insert a '#' using Alt-3 in
;; emacs as we would in other programs.
(fset 'insert-pound "#")
(define-key global-map "\M-3" 'insert-pound)
(when (or *is-carbon-emacs*
*is-cocoa-emacs*)
;; Use solarized-dark from solarized-theme
(defun load-solarized ()
(load-theme 'solarized-dark t))
(setq solarized-high-contrast-mode-line t)
(add-hook 'after-init-hook 'load-solarized)
;; Mac GUI stuff
;; set my favourite Mac font as the default font
(custom-set-faces
'(default ((t (:height 180 :family "Inconsolata")))))
;; meta key configuration
;; This makes left-option do M-
(setq ns-alternate-modifier 'meta)
;; ... and right-option just do option so I can still type
;; alternate characters.
(setq ns-right-alternate-modifier nil)
;; command is super
(setq ns-command-modifier 'super)
;; set fn to hyper
(setq ns-function-modifier 'hyper)
(when (fboundp 'toggle-frame-fullscreen)
(global-set-key (kbd "s-<return>") 'toggle-frame-fullscreen))
(global-set-key (kbd "s-p") 'magit-find-file-completing-read)
(global-set-key (kbd "s-F") 'ag-project)
(global-set-key (kbd "s-b") 'bw-eproject-ido-switch-buffers)
(global-set-key (kbd "H-g") 'magit-status)
;; we pretty much never ever want to background emacs
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z"))
;; Don't open files from the workspace in a new frame
(setq ns-pop-up-frames nil)
;; Emacs launched from the desktop doesn't inherit the shell
;; env. This package:
;; https://github.com/purcell/exec-path-from-shell automatically
;; mirrors the PATH and other environment variables from a login
;; shell, ensuring that things work correctly.
(use-package exec-path-from-shell
:init
(progn
;; copy SHELL correctly
(setq exec-path-from-shell-variables '("PATH" "MANPATH" "SHELL"))
;; copy shell PATH across to exec-path
(exec-path-from-shell-initialize)))
;; load some OSX things
(require 'init-edit-server))
(unless (display-graphic-p)
;; Configuration to make Emacs run semi-normally in an OS X
;; terminal
;; XXX: strongly recommended to run in iTerm2, as it's more
;; configurable than Terminal.app.
;; Make sure cut/paste works properly. Gotten from:
;; http://mindlev.wordpress.com/2011/06/13/emacs-in-a-terminal-on-osx/#comment-20
(defun copy-from-osx ()
"Copies the current clipboard content using the `pbcopy` command"
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
"Copies the top of the kill ring stack to the OSX clipboard"
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
;; Override defaults to use the mac copy and paste
(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx))
(provide 'init-osx)