Back in the day, if my cursor was in the middle of a really long shell command I'd just hit Ctrl+C to get myself a new command prompt.

Then I learned about Ctrl+K/C and life was good. Unfortunately those sequences are a little awkward for me, so now I'd like to map one shortcut to reset the entire line with one sequence.

Is it possible to map something like Ctrl+X so it performs those two commands? I checked the variables in man bash and found kill-whole-line but I'm not sure how to implement it in my .bashrc -- or if that's even what I need (seems like it is).

ED: I learned Ctrl+X might not be the best choice because it's a gateway to other bash shortcuts, so I went with something else.

2 Answers 2


You can add the following line into ~/.inputrc:

"\C-x": kill-whole-line

Or, add the following into your ~/.bashrc:

bind '"\C-x": kill-whole-line'

To see all the possible bindings and which are in effect, run

bind -p

You might need to unbind the combinations that start with \C-x.


It's not possible to assign multiple commands to a single hotkey directly. Normally one would do following in the ~/.inputrc

"\C-x": some-readline-command (eg. kill-whole-line)

However, you can do following to map hotkey to any sequence of input (where you can reference already bound commands by their hotkeys too and hence execute them)

"\C-x": "\C-knew text"

Note: Actually above wouldn't work because \C-x is by default bound as leader key for other bindings (eg. \C-x\C-u for undo in emacs mode). You have to unbind all of those to make pure \C-x do something.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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