From 257908c25366ef5d59c4b3b7976f9baa4e025015 Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 20 Jun 2018 15:34:28 +0200 Subject: Add ways to run shell commands in the minibuffer I sometimes need to create a file named $(date +%F).md. This commit introduces two ways to do this: 1. with recursive minibuffers: C-x C-f M-! date +%F RET 2. with a new function to add shell command outputs to the kill ring: C-x C-f C-c k ! date +%F RET C-y --- .emacs | 7 +++++++ .emacs-custom.el | 2 ++ 2 files changed, 9 insertions(+) diff --git a/.emacs b/.emacs index 961611d..3a5550a 100644 --- a/.emacs +++ b/.emacs @@ -42,6 +42,7 @@ (global-set-key (kbd "C-c f") 'auto-fill-mode) (global-set-key (kbd "C-c k f") 'my/kill-ring-filename) (global-set-key (kbd "C-c k |") 'my/kill-ring-pipe-region) +(global-set-key (kbd "C-c k !") 'my/kill-ring-shell) (global-set-key (kbd "C-c m") 'man) (global-set-key (kbd "C-c p") 'electric-pair-mode) (global-set-key (kbd "C-c t") 'toggle-truncate-lines) @@ -218,6 +219,12 @@ t t nil shell-command-switch command) (kill-new (buffer-string))))) +(defun my/kill-ring-shell (command) + (interactive (list (read-shell-command "Shell command: "))) + (with-temp-buffer + (call-process-shell-command command nil t) + (kill-new (buffer-string)))) + (defun my/froggify () (ispell-change-dictionary "fr") (setq-local colon-double-space nil) diff --git a/.emacs-custom.el b/.emacs-custom.el index 8458d25..2a8c353 100644 --- a/.emacs-custom.el +++ b/.emacs-custom.el @@ -15,6 +15,7 @@ '(ediff-merge-split-window-function (quote split-window-vertically)) '(ediff-split-window-function (quote split-window-horizontally)) '(electric-pair-mode t) + '(enable-recursive-minibuffers t) '(erc-log-channels-directory "~/.irc-logs") '(erc-log-write-after-insert t) '(erc-log-write-after-send t) @@ -39,6 +40,7 @@ '(markdown-enable-math t) '(markdown-header-scaling t) '(menu-bar-mode nil) + '(minibuffer-depth-indicate-mode t) '(package-archives (quote (("melpa" . "https://melpa.org/packages/") -- cgit v1.2.3