4

I would like to define the keybinding C-c s which should start a new shell in the current directory (so C-c s should behave like C-u M-x shell). I know how to define a keybinding based on a function (e.g. (global-set-key (kbd "C-c s") 'shell)), but this problem here is more of the sort "defining a keybinding by another keybinding" (if I try C-h k and then type C-u M-x shell, I get the help for C-u alone (right after typing it)).

marked as duplicate by Drew, DoMiNeLa10 Apr 4 at 20:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Even if it is a duplicate, I would have not found it. If I had known universal-prefix-argument, I would have perhaps found it. I think there is value in having a version with C-u... in the title (which is supported by the number of upvotes in the small amount of time). But thanks for creating the link to the other question. – Marius Hofert Apr 5 at 13:29
5

You need to set universal-prefix-argument and call shell interactively:

(global-set-key
 (kbd "C-c s")
 (lambda ()
   (interactive)
   (let ((current-prefix-arg '(4)))
     (call-interactively #'shell))))

Not the answer you're looking for? Browse other questions tagged or ask your own question.