Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

2 Answers

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.

share|improve this answer
add comment

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

set HISTCONTROL=ignoredups will work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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