1

I constantly need to close and re-open programs. To do this I press Control+C > Up Arrow > Enter. However, I have more than one program and need to run different commands for these programs. If I run another command in a new terminal the history changes for the original terminal and the up arrow is no longer the last command. I'm forever accidentally running random commands in the terminal.

I have tried Control+R to search history and !! but I do this too frequently and they are too slow.

The ideal situation would be that history for a terminal did not change once the terminal was opened. Even better if that can be done only for arrow keys.

The closest I have gotten is a delay on updating the history.

Any suggestions would be greatly appreciated.

3
  • 1
    Have a look at terminal multiplexers (tmux, GNU Screen) so that you can dedicate a terminal to this program you launch/stop/restart repeatedly. Run your other commands in other terminal windows to keep your history clean.
    – Httqm
    Dec 4 '20 at 10:20
  • 1
    Could you just make yourself some 1-character aliases? alias 1='my program with some arguments' Dec 4 '20 at 13:21
  • Thanks for all the great feedback. @KamilMaciorowski I thought I tried this in bash however it appears I am mistaken. I would consider these all viable answers. This is going to save me so much time!
    – Luke
    Dec 5 '20 at 10:03
1

There was a comment that was deleted that explained that Bash did not exhibit the same behavior. That great comment helped me find How to make oh-my-zsh history behavior similar to Bash's?.

I updated ~/.profile with:

bindkey "$terminfo[kcuu1]" up-line-or-history
bindkey "$terminfo[kcud1]" down-line-or-history

Which has solved the problem.

1
  • Can you accept your answer, please, so your question doesn't stay open? Dec 6 '20 at 21:08

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.