Better integrates CLI and Emacsclient
This commit is contained in:
parent
6b3d011491
commit
8fff1ba890
6 changed files with 88 additions and 5 deletions
24
emacs/index.sh
Normal file
24
emacs/index.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
|
||||
if [ -n "$INSIDE_EMACS" ]; then
|
||||
export PAGER="create-shell-pager.sh"
|
||||
else
|
||||
export PAGER="less"
|
||||
fi
|
||||
|
||||
|
||||
if [ -n "$INSIDE_EMACS" ]; then
|
||||
export EDITOR="emacsclient"
|
||||
else
|
||||
export EDITOR=$(which vim)
|
||||
fi
|
||||
|
||||
|
||||
man () {
|
||||
if [ -n "$INSIDE_EMACS" ]; then
|
||||
emacsclient -e "(man \"$1\")"
|
||||
else
|
||||
command man "$1"
|
||||
fi
|
||||
}
|
|
@ -1,3 +1,36 @@
|
|||
(defun wc/open-in-pager (file)
|
||||
(find-file file)
|
||||
(emacs-pager-mode))
|
||||
|
||||
|
||||
(defvar emacs-pager-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map (kbd "q") 'kill-this-buffer)
|
||||
map)
|
||||
"Keymap for emacs pager mode.")
|
||||
|
||||
|
||||
(defcustom emacs-pager-max-line-coloring 500
|
||||
"Maximum number of lines to ansi-color. If performance is bad when
|
||||
loading data, reduce this number"
|
||||
:group 'emacs-pager)
|
||||
|
||||
|
||||
(define-derived-mode emacs-pager-mode fundamental-mode "Pager"
|
||||
"Mode for viewing data paged by emacs-pager"
|
||||
(setq-local make-backup-files nil)
|
||||
(ansi-color-apply-on-region (goto-char (point-min))
|
||||
(save-excursion
|
||||
(forward-line emacs-pager-max-line-coloring)
|
||||
(point)))
|
||||
(setq buffer-name "*pager*")
|
||||
(set-buffer-modified-p nil)
|
||||
(read-only-mode)
|
||||
(evil-define-key 'normal emacs-pager-mode-map
|
||||
(kbd "q") 'kill-this-buffer
|
||||
(kbd "ESC") 'kill-this-buffer))
|
||||
|
||||
|
||||
(defun wc/projectile-shell-pop ()
|
||||
"Opens `ansi-term' at the project root according to Projectile."
|
||||
(interactive)
|
||||
|
@ -29,6 +62,15 @@
|
|||
:buffer "*helm projectile terminals*"))
|
||||
|
||||
|
||||
(defun wc/git-changed-files ()
|
||||
"Lists active terminal buffers."
|
||||
(interactive)
|
||||
(helm :sources (helm-build-in-buffer-source "test1"
|
||||
:data ((lambda () (shell-command-to-string "wc-git-changed-files")))
|
||||
:action 'term-send-raw-string)
|
||||
:buffer "*helm git changed file*"))
|
||||
|
||||
|
||||
(defun wc/shell-history ()
|
||||
(setq history (shell-command-to-string "history"))
|
||||
(split-string history "\n"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue