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)).

  • 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 '19 at 13:29

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

 (kbd "C-c s")
 (lambda ()
   (let ((current-prefix-arg '(4)))
     (call-interactively #'shell))))
| improve this answer | |

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