Skip to content

Commit

Permalink
Add Emacs init.el
Browse files Browse the repository at this point in the history
  • Loading branch information
nyxkrage committed Dec 16, 2022
1 parent 0ad63a8 commit 892fdef
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .emacs.d/init.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
;;; init.el --- Emacs-OS Init System -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2022 Carsten Kragelund
;;
;; Author: Carsten Kragelund <[email protected]>
;; Maintainer: Carsten Kragelund <[email protected]>
;; Created: December 16, 2022
;; Modified: December 16, 2022
;; Version: 1.0.0
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp
;; Homepage: https://github.com/nyxkrage/emacs-os
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; This is the Emacs-OS init.el file which sets up reboot and shutdown commands
;; and makes sure that the root filesystem gets mounted as rw
;;
;;; Code:

(message "init starting")
(setq auto-save-interval 0)

(defun save-all-buffers ()
(save-some-buffers nil t))

(defun reboot ()
(interactive)
(when (yes-or-no-p "Really reboot the system? ")
(save-all-buffers)
(if (file-exists-p "/etc/mtab") (delete-file "/etc/mtab"))
(call-process "/sbin/mount" nil nil nil "-n" "-o" "ro,remount" "/")
(call-process "/sbin/reboot" nil nil nil)))

(defun shutdown ()
(interactive)
(when (yes-or-no-p "Really shut down the system? ")
(save-all-buffers)
(if (file-exists-p "/etc/mtab") (delete-file "/etc/mtab"))
(call-process "/sbin/mount" nil nil nil "-n" "-o" "ro,remount" "/")
(call-process "/sbin/shutdown" nil nil nil)))

;; Global keybindings
(global-set-key "\C-x\C-z" 'reboot)
(global-set-key "\C-x\C-c" 'shutdown)
(global-set-key "\C-\M-s" 'eshell)

(global-set-key "^" 'keyboard-quit) ;; strangely, C-g does not work.

;; Add some standard directories to exec-path to use in eshell
(setenv "PATH" "/bin:/sbin")

;; Mount various needed virtual/tmp filesystem
(call-process "/sbin/mount" nil "*log*" nil "-t" "proc" "proc" "/proc")
(call-process "/sbin/mount" nil "*log*" nil "-o" "rw,remount" "/")
(call-process "/sbin/mount" nil "*log*" nil "-t" "sysfs" "sys" "/sys")
(call-process "/sbin/mount" nil "*log*" nil "-t" "tmpfs" "run" "/run")
(call-process "/sbin/mount" nil "*log*" nil "-t" "devtmpfs" "dev" "/dev")

(custom-set-variables
'(inhibit-startup-screen t)
'(initial-buffer-choice nil))

(message "init done")

(eshell)

(provide 'init)
;;; init.el ends here

0 comments on commit 892fdef

Please sign in to comment.