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?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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.
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.