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)).
Asked
Active
Viewed 272 times
4
Drew
- 75,699
- 9
- 109
- 225
Marius Hofert
- 349
- 1
- 9
-
1Even 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 05 '19 at 13:29
1 Answers
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))))
muffinmad
- 2,250
- 7
- 11