Move eshell settings to org
This commit is contained in:
parent
5a1e9f2ea8
commit
7d719f694b
3 changed files with 93 additions and 52 deletions
|
@ -23,7 +23,6 @@
|
|||
"Face for the supposedly empty line in commit messages."
|
||||
:group 'local)
|
||||
|
||||
(eval-after-load "em-term" '(add-to-list 'eshell-visual-commands "unison"))
|
||||
(eval-after-load "emms-source-file" '(oni:emms-init))
|
||||
(eval-after-load "flymake" '(oni:flymake-init))
|
||||
(eval-after-load "ido" '(oni:ido-init))
|
||||
|
@ -107,9 +106,6 @@
|
|||
(setq erc-nick "ryuslash")
|
||||
(setq erc-timestamp-format "[%H:%M] ")
|
||||
(setq erc-timestamp-only-if-changed-flag nil)
|
||||
(setq eshell-highlight-prompt nil)
|
||||
(setq eshell-prompt-function 'oni:eshell-prompt-function)
|
||||
(setq eshell-prompt-regexp "^[#$]> ")
|
||||
(setq fci-rule-color "darkred")
|
||||
(setq flymake-gui-warnings-enabled nil)
|
||||
(setq flymake-info-line-regexp
|
||||
|
@ -235,7 +231,6 @@
|
|||
(add-hook 'diary-display-hook 'oni:diary-display-func)
|
||||
(add-hook 'emacs-lisp-mode-hook 'oni:emacs-lisp-mode-func)
|
||||
(add-hook 'erc-mode-hook 'oni:erc-mode-func)
|
||||
(add-hook 'eshell-mode-hook 'oni:eshell-mode-func)
|
||||
(add-hook 'flymake-mode-hook 'oni:flymake-mode-func)
|
||||
(add-hook 'go-mode-hook 'oni:go-mode-func)
|
||||
(add-hook 'gtags-mode-hook 'oni:gtags-mode-func)
|
||||
|
@ -275,7 +270,6 @@
|
|||
(global-set-key (kbd "<f5>") 'ext:reload-buffer)
|
||||
(global-set-key (kbd "<f6>") 'jabber-switch-to-roster-buffer)
|
||||
(global-set-key (kbd "<f7>") 'magit-status)
|
||||
(global-set-key (kbd "<f8>") 'oni:raise-eshell)
|
||||
(global-set-key (kbd "C-<") 'oni:indent-shift-left)
|
||||
(global-set-key (kbd "C->") 'oni:indent-shift-right)
|
||||
(global-set-key (kbd "C-M-4") 'split-window-vertically)
|
||||
|
|
|
@ -82,3 +82,96 @@
|
|||
#+BEGIN_SRC emacs-lisp :tangle init2.el
|
||||
(eval-after-load "eldoc" '(diminish 'eldoc-mode))
|
||||
#+END_SRC
|
||||
|
||||
** Eshell
|
||||
|
||||
Add ~unison~ to the list of =eshell-visual-commands= because it
|
||||
expects unbuffered input and eshell just doesn't give that.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle init2.el
|
||||
(eval-after-load "em-term"
|
||||
'(add-to-list 'eshell-visual-commands "unison"))
|
||||
#+END_SRC
|
||||
|
||||
Don't let eshell highlight it's prompt, this way I can decide the
|
||||
colors for it myself.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle init2.el
|
||||
(setq eshell-highlight-prompt nil)
|
||||
#+END_SRC
|
||||
|
||||
In the prompt:
|
||||
|
||||
- Show the exit status of the last program/command run represented
|
||||
by a green ~+~ and a red ~-~ sign.
|
||||
- Show the current hostname with the =mode-line-buffer-id= face.
|
||||
- Show an abbreviation of the current directory (as seen in ~fish~)
|
||||
using the =font-lock-string-face= face.
|
||||
- If we're in a git repository, show the current branch with the
|
||||
=font-lock-function-name-face= face.
|
||||
- Show the status of priviledges in blue.
|
||||
|
||||
And set the =eshell-prompt-regexp= to
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle init2.el
|
||||
(defun oni:eshell-prompt-function ()
|
||||
"Show a pretty shell prompt."
|
||||
(let ((status (if (zerop eshell-last-command-status) ?+ ?-))
|
||||
(hostname (shell-command-to-string "hostname"))
|
||||
(dir (abbreviate-file-name (eshell/pwd)))
|
||||
(branch
|
||||
(shell-command-to-string
|
||||
"git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'"))
|
||||
(userstatus (if (zerop (user-uid)) ?# ?$)))
|
||||
(concat
|
||||
(propertize (char-to-string status)
|
||||
'face `(:foreground ,(if (= status ?+)
|
||||
"green"
|
||||
"red")))
|
||||
" "
|
||||
(propertize (substring hostname 0 -1) 'face 'mode-line-buffer-id)
|
||||
" "
|
||||
(propertize (oni:shorten-dir dir) 'face 'font-lock-string-face)
|
||||
" "
|
||||
(when (not (string= branch ""))
|
||||
(propertize
|
||||
;; Cut off "* " and "\n"
|
||||
(substring branch 2 -1)
|
||||
'face 'font-lock-function-name-face))
|
||||
" \n"
|
||||
(propertize (char-to-string userstatus)
|
||||
'face `(:foreground "blue"))
|
||||
"> ")))
|
||||
|
||||
(setq eshell-prompt-function 'oni:eshell-prompt-function
|
||||
eshell-prompt-regexp "^[#$]> ")
|
||||
#+END_SRC
|
||||
|
||||
Don't truncate lines in eshell, wrap them.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle init2.el
|
||||
(defun oni:eshell-mode-func ()
|
||||
"Function for `eshell-mode-hook'."
|
||||
(setq truncate-lines nil))
|
||||
|
||||
(add-hook 'eshell-mode-hook 'oni:eshell-mode-func)
|
||||
#+END_SRC
|
||||
|
||||
Bind the ~f8~ key to easily show eshell.
|
||||
|
||||
#+BEGIN_SRC emacs-lisp :tangle init2.el
|
||||
(defun oni:raise-eshell ()
|
||||
"Start or switch back to `eshell'.
|
||||
Also change directories to current working directory."
|
||||
(interactive)
|
||||
(let ((dir (file-name-directory
|
||||
(or (buffer-file-name) "~/")))
|
||||
(hasfile (not (eq (buffer-file-name) nil))))
|
||||
(eshell)
|
||||
(if (and hasfile (eq eshell-process-list nil))
|
||||
(progn
|
||||
(eshell/cd dir)
|
||||
(eshell-reset)))))
|
||||
|
||||
(global-set-key (kbd "<f8>") 'oni:raise-eshell)
|
||||
#+END_SRC
|
||||
|
|
|
@ -147,39 +147,6 @@ DOT are intentionally being skipped."
|
|||
(visual-line-mode)
|
||||
(setq truncate-lines nil))
|
||||
|
||||
(defun oni:eshell-mode-func ()
|
||||
"Function for `eshell-mode-hook'."
|
||||
(setq truncate-lines nil))
|
||||
|
||||
(defun oni:eshell-prompt-function ()
|
||||
"Show a pretty shell prompt."
|
||||
(let ((status (if (zerop eshell-last-command-status) ?+ ?-))
|
||||
(hostname (shell-command-to-string "hostname"))
|
||||
(dir (abbreviate-file-name (eshell/pwd)))
|
||||
(branch
|
||||
(shell-command-to-string
|
||||
"git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d'"))
|
||||
(userstatus (if (zerop (user-uid)) ?# ?$)))
|
||||
(concat
|
||||
(propertize (char-to-string status)
|
||||
'face `(:foreground ,(if (= status ?+)
|
||||
"green"
|
||||
"red")))
|
||||
" "
|
||||
(propertize (substring hostname 0 -1) 'face 'mode-line-buffer-id)
|
||||
" "
|
||||
(propertize (oni:shorten-dir dir) 'face 'font-lock-string-face)
|
||||
" "
|
||||
(when (not (string= branch ""))
|
||||
(propertize
|
||||
;; Cut off "* " and "\n"
|
||||
(substring branch 2 -1)
|
||||
'face 'font-lock-function-name-face))
|
||||
" \n"
|
||||
(propertize (char-to-string userstatus)
|
||||
'face `(:foreground "blue"))
|
||||
"> ")))
|
||||
|
||||
(defun oni:flymake-init ()
|
||||
"Initialization function for flymake."
|
||||
(require 'flymake-cursor)
|
||||
|
@ -492,19 +459,6 @@ ignored."
|
|||
(switch-to-buffer buffer)
|
||||
(call-interactively 'ansi-term))))
|
||||
|
||||
(defun oni:raise-eshell ()
|
||||
"Start or switch back to `eshell'.
|
||||
Also change directories to current working directory."
|
||||
(interactive)
|
||||
(let ((dir (file-name-directory
|
||||
(or (buffer-file-name) "~/")))
|
||||
(hasfile (not (eq (buffer-file-name) nil))))
|
||||
(eshell)
|
||||
(if (and hasfile (eq eshell-process-list nil))
|
||||
(progn
|
||||
(eshell/cd dir)
|
||||
(eshell-reset)))))
|
||||
|
||||
(defun oni:raise-scratch (&optional mode)
|
||||
"Show the *scratch* buffer.
|
||||
If called with a universal argument, ask the user which mode to
|
||||
|
|
Loading…
Reference in a new issue