When I paste a command to my OS X or Ubuntu bash prompt using CmdV, the command is not in history – even if it is executed. The command is in history only if I type it.

How to enable that pasted commands get into bash's history?

  • 2
    This is implausible. Your shell (bash), which is responsible for storing history, does not know whether you pasted or typed something. There must be some other difference in what you are doing that is causing this result. – Kevin Reid Feb 20 '12 at 23:15
  • 1
    @Kevin Reid, normally I'd agree with you, but this is OS X and since bash is FOSS software, who KNOWS what Apple has done to it. – UtahJarhead Oct 19 '12 at 12:38

There's an 'ignorespace' directive that won't save commands with blankspace at the start of the line, which is possible when you're cutting and pasting. There's an 'ignoredups' directive that only saves the earliest instance of a command, which might be the case here if you have a long history file and have used the command before. But, both of these are unset on my OSX10.6 machine, so unless you turned it on, these probably don't explain your situation.

Other scenario is that you've su-ed into another user, which could well be the case if you're cutting and pasting commands from somewhere else to get something fixed, so when you drop out of that user's (usually the root user's) context, the bash history is not available to you because it's in the privileged user's history, not yours.

| improve this answer | |

You can set HISTCONTROL to something else than ignorespace or ignoreboth.

set HISTCONTROL=ignoredups will work.

| improve this answer | |

I had this problem in the KDE Konsole.

editing my .bashrc to change




fixed it. I guess i must have wanted the handy "don't add it to my history if i put a space in front" in the past, but i do a lot of copying and pasting between terminals now and it was getting really annoying.

| improve this answer | |

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.