I have <f5>
bound to projectile-run-project
. When pressing <f5>
, the minibuffer displays the command to run and you need to press RET
to confirm it.
How can I add the behavior that when <f5>
is pressed again, it acts as a RET
to confirm and execute the command?
UPDATE: my working projectile config after the answer from @Tobias
(use-package projectile
:init (setq
projectile-project-search-path '("c:/repo") ;; todo make variable and declare it in paths
projectile-enable-caching t
projectile-completion-system 'helm
projectile-indexing-method 'native)
(add-hook 'ibuffer-hook
(lambda ()
(ibuffer-projectile-set-filter-groups)
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic))))
;; projectile-globally-ignored-file-suffixes
;; (append '("S" "elf" "o") projectile-globally-ignored-file-suffixes))
:bind-keymap
("C-c p" . projectile-command-map)
:bind
("<f5>" . projectile-run-project)
:config (projectile-mode +1))
(defun my-read-shell-command-key-wrapper (oldfun &rest args)
"Wrapper for `projectile-run-project' that temporarily adds <f5> to the keymap."
(let ((minibuffer-local-shell-command-map (copy-sequence minibuffer-local-shell-command-map)))
(define-key minibuffer-local-shell-command-map (kbd "<f5>") (kbd "RET"))
(apply oldfun args)))
(advice-add 'projectile-run-project :around #'my-read-shell-command-key-wrapper)