Various command-line tools, such as gdb, ftp, sftp, etc, use ! to prefix a command to be run in a shell. So (for instance) !mkdir foo will make a directory called foo. When using these tools inside emacs shell-mode, the shell-mode treats the ! as a history reference, does a history lookup, and expands the result before putting the command in the history ring. So if I have previously typed mkdir bar, shell-mode puts mkdir bar foo into the history ring.

Can I easily suppress all special treatment of ! in the shell history? I want the history to contain !mkdir foo. I don't ever use ! at the shell, so I'd be happy with a way of turning this off entirely, although I suppose it could be made switchable based on the prompt.


Figured it out: (setq shell-input-autoexpand nil). I spent a long while looking at comint-input-autoexpand which was getting mysteriously set to 'history: this is done by shell-mode based on shell-input-autoexpand. I don't see an easy way to make it prompt-dependent, though.

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.