2015-05-21 02:39:14 +00:00
|
|
|
;;; packages.el --- shell packages File for Spacemacs
|
|
|
|
;;
|
2018-01-04 07:00:25 +00:00
|
|
|
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors
|
2015-05-21 02:39:14 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
|
|
(setq shell-packages
|
|
|
|
'(
|
2016-01-26 05:47:10 +00:00
|
|
|
(comint :location built-in)
|
2015-07-08 04:57:15 +00:00
|
|
|
company
|
2016-01-26 05:47:10 +00:00
|
|
|
esh-help
|
|
|
|
(eshell :location built-in)
|
|
|
|
eshell-prompt-extras
|
|
|
|
eshell-z
|
2015-05-21 02:39:14 +00:00
|
|
|
helm
|
2016-01-26 05:47:10 +00:00
|
|
|
magit
|
2015-05-25 02:01:26 +00:00
|
|
|
multi-term
|
2016-04-04 13:48:34 +00:00
|
|
|
org
|
2016-02-02 15:42:58 +00:00
|
|
|
projectile
|
2016-01-26 05:47:10 +00:00
|
|
|
(shell :location built-in)
|
2015-05-21 02:39:14 +00:00
|
|
|
shell-pop
|
2016-01-26 05:47:10 +00:00
|
|
|
(term :location built-in)
|
|
|
|
xterm-color
|
2016-04-29 21:48:00 +00:00
|
|
|
vi-tilde-fringe
|
2015-05-21 02:39:14 +00:00
|
|
|
))
|
|
|
|
|
2016-01-26 05:47:10 +00:00
|
|
|
(defun shell/init-comint ()
|
2016-02-27 23:25:33 +00:00
|
|
|
(setq comint-prompt-read-only t)
|
|
|
|
(add-hook 'comint-mode-hook 'spacemacs/disable-hl-line-mode))
|
2016-01-26 05:47:10 +00:00
|
|
|
|
2015-07-24 02:21:51 +00:00
|
|
|
(defun shell/pre-init-company ()
|
2015-07-08 04:57:15 +00:00
|
|
|
;; support in eshell
|
|
|
|
(spacemacs|use-package-add-hook eshell
|
2015-09-14 13:09:28 +00:00
|
|
|
:post-init
|
|
|
|
(progn
|
2017-01-02 05:39:04 +00:00
|
|
|
(spacemacs|add-company-backends :backends company-capf :modes eshell-mode)
|
2015-07-10 09:51:40 +00:00
|
|
|
(add-hook 'eshell-directory-change-hook
|
|
|
|
'spacemacs//toggle-shell-auto-completion-based-on-path)
|
2015-07-08 04:57:15 +00:00
|
|
|
;; The default frontend screws everything up in short windows like
|
|
|
|
;; terminal often are
|
2015-08-11 02:12:27 +00:00
|
|
|
(add-hook 'eshell-mode-hook
|
2015-09-14 13:09:28 +00:00
|
|
|
'spacemacs//eshell-switch-company-frontend))))
|
2015-07-08 04:57:15 +00:00
|
|
|
|
2016-01-26 05:47:10 +00:00
|
|
|
(defun shell/init-esh-help ()
|
|
|
|
(use-package esh-help
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-01-26 05:47:10 +00:00
|
|
|
:init (add-hook 'eshell-mode-hook 'eldoc-mode)
|
|
|
|
:config (setup-esh-help-eldoc)))
|
|
|
|
|
2015-07-08 05:02:00 +00:00
|
|
|
(defun shell/init-eshell ()
|
|
|
|
(use-package eshell
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-07-08 05:02:00 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-01-22 15:26:52 +00:00
|
|
|
(spacemacs/register-repl 'eshell 'eshell)
|
2015-07-08 05:02:00 +00:00
|
|
|
(setq eshell-cmpl-cycle-completions nil
|
|
|
|
;; auto truncate after 20k lines
|
|
|
|
eshell-buffer-maximum-lines 20000
|
|
|
|
;; history size
|
|
|
|
eshell-history-size 350
|
2015-12-24 03:01:00 +00:00
|
|
|
;; no duplicates in history
|
|
|
|
eshell-hist-ignoredups t
|
2015-07-08 05:02:00 +00:00
|
|
|
;; buffer shorthand -> echo foo > #'buffer
|
|
|
|
eshell-buffer-shorthand t
|
|
|
|
;; my prompt is easy enough to see
|
|
|
|
eshell-highlight-prompt nil
|
|
|
|
;; treat 'echo' like shell echo
|
2016-02-17 04:40:25 +00:00
|
|
|
eshell-plain-echo-behavior t
|
|
|
|
;; cache directory
|
|
|
|
eshell-directory-name (concat spacemacs-cache-directory "eshell/"))
|
2015-07-08 05:02:00 +00:00
|
|
|
|
2015-07-10 23:58:13 +00:00
|
|
|
(when shell-protect-eshell-prompt
|
2015-07-26 06:41:26 +00:00
|
|
|
(add-hook 'eshell-after-prompt-hook 'spacemacs//protect-eshell-prompt))
|
2015-07-10 23:58:13 +00:00
|
|
|
|
2016-01-21 21:11:49 +00:00
|
|
|
(autoload 'eshell-delchar-or-maybe-eof "em-rebind")
|
2015-12-24 03:01:00 +00:00
|
|
|
|
2016-02-27 23:25:33 +00:00
|
|
|
(add-hook 'eshell-mode-hook 'spacemacs//init-eshell)
|
|
|
|
(add-hook 'eshell-mode-hook 'spacemacs/disable-hl-line-mode))
|
2015-07-08 05:02:00 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2017-04-10 02:56:39 +00:00
|
|
|
|
|
|
|
;; Work around bug in eshell's preoutput-filter code.
|
|
|
|
;; Eshell doesn't call preoutput-filter functions in the context of the eshell
|
|
|
|
;; buffer. This breaks the xterm color filtering when the eshell buffer is updated
|
|
|
|
;; when it's not currently focused.
|
|
|
|
;; To remove if/when fixed upstream.
|
2017-04-29 22:50:15 +00:00
|
|
|
(defun eshell-output-filter@spacemacs-with-buffer (fn process string)
|
2017-04-05 03:31:37 +00:00
|
|
|
(let ((proc-buf (if process (process-buffer process)
|
|
|
|
(current-buffer))))
|
|
|
|
(when proc-buf
|
|
|
|
(with-current-buffer proc-buf
|
|
|
|
(funcall fn process string)))))
|
2017-04-29 22:50:15 +00:00
|
|
|
(advice-add
|
|
|
|
#'eshell-output-filter
|
|
|
|
:around
|
|
|
|
#'eshell-output-filter@spacemacs-with-buffer)
|
2017-04-05 03:31:37 +00:00
|
|
|
|
2015-07-08 05:02:00 +00:00
|
|
|
(require 'esh-opt)
|
|
|
|
|
|
|
|
;; quick commands
|
2016-02-07 01:50:06 +00:00
|
|
|
(defalias 'eshell/e 'find-file-other-window)
|
|
|
|
(defalias 'eshell/d 'dired)
|
2015-07-08 05:02:00 +00:00
|
|
|
(setenv "PAGER" "cat")
|
|
|
|
|
|
|
|
;; support `em-smart'
|
|
|
|
(when shell-enable-smart-eshell
|
|
|
|
(require 'em-smart)
|
|
|
|
(setq eshell-where-to-jump 'begin
|
|
|
|
eshell-review-quick-commands nil
|
|
|
|
eshell-smart-space-goes-to-end t)
|
|
|
|
(add-hook 'eshell-mode-hook 'eshell-smart-initialize))
|
|
|
|
|
|
|
|
;; Visual commands
|
|
|
|
(require 'em-term)
|
2018-06-01 06:59:57 +00:00
|
|
|
(mapc (lambda (x) (add-to-list 'eshell-visual-commands x))
|
2015-07-08 05:02:00 +00:00
|
|
|
'("el" "elinks" "htop" "less" "ssh" "tmux" "top"))
|
|
|
|
|
|
|
|
;; automatically truncate buffer after output
|
|
|
|
(when (boundp 'eshell-output-filter-functions)
|
2018-06-01 06:59:57 +00:00
|
|
|
(add-hook 'eshell-output-filter-functions #'eshell-truncate-buffer)))))
|
2015-07-08 05:02:00 +00:00
|
|
|
|
|
|
|
(defun shell/init-eshell-prompt-extras ()
|
|
|
|
(use-package eshell-prompt-extras
|
|
|
|
:commands epe-theme-lambda
|
|
|
|
:init
|
|
|
|
(setq eshell-highlight-prompt nil
|
|
|
|
eshell-prompt-function 'epe-theme-lambda)))
|
|
|
|
|
2016-01-26 05:47:10 +00:00
|
|
|
(defun shell/init-eshell-z ()
|
|
|
|
(use-package eshell-z
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2016-01-26 05:47:10 +00:00
|
|
|
:init
|
|
|
|
(with-eval-after-load 'eshell
|
|
|
|
(require 'eshell-z))))
|
|
|
|
|
2016-05-30 02:39:21 +00:00
|
|
|
(defun shell/pre-init-helm ()
|
|
|
|
(spacemacs|use-package-add-hook helm
|
|
|
|
:post-init
|
|
|
|
(progn
|
|
|
|
;; eshell
|
|
|
|
(add-hook 'eshell-mode-hook 'spacemacs/init-helm-eshell)
|
|
|
|
;;shell
|
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'shell-mode
|
|
|
|
"H" 'spacemacs/helm-shell-history))))
|
2015-05-25 02:01:26 +00:00
|
|
|
|
2016-01-26 05:47:10 +00:00
|
|
|
(defun shell/pre-init-magit ()
|
|
|
|
(spacemacs|use-package-add-hook magit
|
|
|
|
:post-init
|
|
|
|
(defalias 's 'magit-status)))
|
|
|
|
|
2015-05-25 02:01:26 +00:00
|
|
|
(defun shell/init-multi-term ()
|
|
|
|
(use-package multi-term
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-05-25 02:01:26 +00:00
|
|
|
:init
|
|
|
|
(progn
|
2016-08-17 19:00:16 +00:00
|
|
|
(spacemacs/register-repl 'multi-term 'multi-term))
|
2015-05-25 02:01:26 +00:00
|
|
|
:config
|
|
|
|
(progn
|
2015-05-31 22:06:35 +00:00
|
|
|
(add-to-list 'term-bind-key-alist '("<tab>" . term-send-tab))
|
2015-07-06 22:55:04 +00:00
|
|
|
;; multi-term commands to create terminals and move through them.
|
2016-05-31 01:04:04 +00:00
|
|
|
(spacemacs/set-leader-keys-for-major-mode 'term-mode
|
|
|
|
"c" 'multi-term
|
|
|
|
"p" 'multi-term-prev
|
|
|
|
"n" 'multi-term-next))))
|
2015-05-21 02:39:14 +00:00
|
|
|
|
2016-04-04 13:48:34 +00:00
|
|
|
(defun shell/pre-init-org ()
|
|
|
|
(spacemacs|use-package-add-hook org
|
|
|
|
:post-config (add-to-list 'org-babel-load-languages '(shell . t))))
|
|
|
|
|
2016-02-02 15:42:58 +00:00
|
|
|
(defun shell/post-init-projectile ()
|
2016-05-30 13:11:43 +00:00
|
|
|
(spacemacs/set-leader-keys
|
|
|
|
"p'" 'spacemacs/projectile-shell-pop
|
|
|
|
"p$t" 'projectile-multi-term-in-root))
|
2016-02-02 15:42:58 +00:00
|
|
|
|
2015-07-02 14:53:52 +00:00
|
|
|
(defun shell/init-shell ()
|
2016-01-22 15:26:52 +00:00
|
|
|
(spacemacs/register-repl 'shell 'shell)
|
2015-05-21 02:39:14 +00:00
|
|
|
(defun shell-comint-input-sender-hook ()
|
|
|
|
"Check certain shell commands.
|
|
|
|
Executes the appropriate behavior for certain commands."
|
|
|
|
(setq comint-input-sender
|
|
|
|
(lambda (proc command)
|
|
|
|
(cond
|
|
|
|
;; Check for clear command and execute it.
|
|
|
|
((string-match "^[ \t]*clear[ \t]*$" command)
|
|
|
|
(comint-send-string proc "\n")
|
2018-10-05 13:18:46 +00:00
|
|
|
(let ((inhibit-read-only t))
|
|
|
|
(erase-buffer)))
|
2015-05-21 02:39:14 +00:00
|
|
|
;; Check for man command and execute it.
|
|
|
|
((string-match "^[ \t]*man[ \t]*" command)
|
|
|
|
(comint-send-string proc "\n")
|
2016-01-26 05:47:10 +00:00
|
|
|
(setq command (replace-regexp-in-string
|
|
|
|
"^[ \t]*man[ \t]*" "" command))
|
|
|
|
(setq command (replace-regexp-in-string
|
|
|
|
"[ \t]+$" "" command))
|
2015-05-21 02:39:14 +00:00
|
|
|
(funcall 'man command))
|
|
|
|
;; Send other commands to the default handler.
|
|
|
|
(t (comint-simple-send proc command))))))
|
2016-02-27 23:25:33 +00:00
|
|
|
(add-hook 'shell-mode-hook 'shell-comint-input-sender-hook)
|
|
|
|
(add-hook 'shell-mode-hook 'spacemacs/disable-hl-line-mode))
|
2015-05-21 02:39:14 +00:00
|
|
|
|
|
|
|
(defun shell/init-shell-pop ()
|
|
|
|
(use-package shell-pop
|
2018-03-04 04:37:53 +00:00
|
|
|
:defer t
|
2015-05-21 02:39:14 +00:00
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
(setq shell-pop-window-position shell-default-position
|
2016-01-26 16:58:40 +00:00
|
|
|
shell-pop-window-size shell-default-height
|
2015-05-21 04:53:54 +00:00
|
|
|
shell-pop-term-shell shell-default-term-shell
|
2016-04-28 14:22:01 +00:00
|
|
|
shell-pop-full-span shell-default-full-span)
|
2015-05-21 02:39:14 +00:00
|
|
|
(make-shell-pop-command eshell)
|
|
|
|
(make-shell-pop-command term shell-pop-term-shell)
|
|
|
|
(make-shell-pop-command ansi-term shell-pop-term-shell)
|
2018-10-11 14:51:02 +00:00
|
|
|
(make-shell-pop-command inferior-shell)
|
|
|
|
(make-shell-pop-command multiterm)
|
2015-05-21 02:39:14 +00:00
|
|
|
|
2015-05-21 10:31:48 +00:00
|
|
|
(add-hook 'term-mode-hook 'ansi-term-handle-close)
|
2015-10-24 20:56:58 +00:00
|
|
|
(add-hook 'term-mode-hook (lambda () (linum-mode -1)))
|
2015-05-22 11:39:01 +00:00
|
|
|
|
2015-11-18 00:38:05 +00:00
|
|
|
(spacemacs/set-leader-keys
|
2015-05-23 01:23:53 +00:00
|
|
|
"'" 'spacemacs/default-pop-shell
|
2016-04-07 18:52:41 +00:00
|
|
|
"ase" 'spacemacs/shell-pop-eshell
|
|
|
|
"asi" 'spacemacs/shell-pop-shell
|
|
|
|
"asm" 'spacemacs/shell-pop-multiterm
|
|
|
|
"ast" 'spacemacs/shell-pop-ansi-term
|
|
|
|
"asT" 'spacemacs/shell-pop-term))))
|
2015-05-21 02:39:14 +00:00
|
|
|
|
|
|
|
(defun shell/init-term ()
|
2016-01-22 15:26:52 +00:00
|
|
|
(spacemacs/register-repl 'term 'term)
|
|
|
|
(spacemacs/register-repl 'term 'ansi-term)
|
2015-05-21 02:39:14 +00:00
|
|
|
(defun term-send-tab ()
|
|
|
|
"Send tab in term mode."
|
|
|
|
(interactive)
|
|
|
|
(term-send-raw-string "\t"))
|
2016-01-30 11:32:53 +00:00
|
|
|
;; hack to fix pasting issue, the paste transient-state won't
|
2015-05-21 02:39:14 +00:00
|
|
|
;; work in term
|
|
|
|
(evil-define-key 'normal term-raw-map "p" 'term-paste)
|
|
|
|
(evil-define-key 'insert term-raw-map (kbd "C-c C-d") 'term-send-eof)
|
2015-12-03 21:21:45 +00:00
|
|
|
(evil-define-key 'insert term-raw-map (kbd "C-c C-z") 'term-stop-subjob)
|
2015-11-13 11:20:55 +00:00
|
|
|
(evil-define-key 'insert term-raw-map (kbd "<tab>") 'term-send-tab)
|
|
|
|
|
2016-03-09 09:06:28 +00:00
|
|
|
(when (eq dotspacemacs-editing-style 'vim)
|
|
|
|
(evil-define-key 'insert term-raw-map
|
|
|
|
(kbd "C-k") 'term-send-up
|
|
|
|
(kbd "C-j") 'term-send-down))
|
2015-11-13 11:20:55 +00:00
|
|
|
(evil-define-key 'normal term-raw-map
|
|
|
|
(kbd "C-k") 'term-send-up
|
2016-02-27 23:25:33 +00:00
|
|
|
(kbd "C-j") 'term-send-down)
|
|
|
|
|
|
|
|
(add-hook 'term-mode-hook 'spacemacs/disable-hl-line-mode))
|
2015-05-22 19:11:56 +00:00
|
|
|
|
2016-01-26 05:47:10 +00:00
|
|
|
(defun shell/init-xterm-color ()
|
|
|
|
(use-package xterm-color
|
|
|
|
:init
|
|
|
|
(progn
|
|
|
|
;; Comint and Shell
|
|
|
|
(add-hook 'comint-preoutput-filter-functions 'xterm-color-filter)
|
|
|
|
(setq comint-output-filter-functions
|
|
|
|
(remove 'ansi-color-process-output comint-output-filter-functions))
|
2016-04-06 12:41:19 +00:00
|
|
|
(add-hook 'eshell-mode-hook 'spacemacs/init-eshell-xterm-color))))
|
2016-04-29 21:48:00 +00:00
|
|
|
|
|
|
|
(defun shell/post-init-vi-tilde-fringe ()
|
|
|
|
(spacemacs/add-to-hooks 'spacemacs/disable-vi-tilde-fringe
|
|
|
|
'(comint-mode-hook
|
|
|
|
eshell-mode-hook
|
|
|
|
shell-mode-hook
|
|
|
|
term-mode-hook)))
|