This commit is contained in:
Abraham Raji 2020-01-15 21:57:56 +05:30
parent 6e13f5be91
commit 5f238ee244
1 changed files with 38 additions and 0 deletions

View File

@ -411,3 +411,41 @@ Scrolling through the output and searching for results that can be copied to the
(define-key eshell-mode-map (kbd "M-S-N") 'eshell-next-prompt)
(define-key eshell-mode-map (kbd "M-r") 'eshell-insert-history)))
#+END_SRC
** Helpers
Sometimes you just need to change something about the current file
you are editing...like the permissions or even execute it. Hitting
=Command-1= will prompt for a shell command string and then append
the current file to it and execute it.
#+BEGIN_SRC emacs-lisp
(defun execute-command-on-file-buffer (cmd)
(interactive "sCommand to execute: ")
(let* ((file-name (buffer-file-name))
(full-cmd (concat cmd " " file-name)))
(shell-command full-cmd)))
(bind-key "A-1" #'execute-command-on-file-buffer)
(defun execute-command-on-file-directory (cmd)
(interactive "sCommand to execute: ")
(let* ((dir-name (file-name-directory (buffer-file-name)))
(full-cmd (concat "cd " dir-name "; " cmd)))
(shell-command full-cmd)))
(bind-key "A-!" #'execute-command-on-file-directory)
(bind-key "s-!" #'execute-command-on-file-directory)
#+END_SRC
Some prompts, shells and terminal programs that display the exit
code as an icon in the fringe. So can the [[http://projects.ryuslash.org/eshell-fringe-status/][eshell-fringe-status]]
project. Seems to me, that if would be useful to rejuggle those
fringe markers so that the marker matched the command entered
(instead of seeing a red mark, and needing to scroll back in order
to wonder what command it was that made it). Still...
#+BEGIN_SRC emacs-lisp
(use-package eshell-fringe-status
:config
(add-hook 'eshell-mode-hook 'eshell-fringe-status-mode))
#+END_SRC