Awesome Programming Knowledge
  • Introduction
  • Writing Better Code
    • Books
      • Refactoring: Improving the Design of Existing Code
        • Extract Method
        • Quotes
          • CodeForHuman
          • Make Comment Superfluous
          • The Rule of Three
      • Clean code: A Handbook of Agile Software Craftsmanship
        • Meaningful name
        • Single Level of Abstraction
        • Small Functions
        • Avoid having BOOL Function Parameters
      • Working effectively with legacy code
        • Sprout Method
      • Code Complete
        • Minimizing Scope
        • Avoid variables with hidden meanings
        • Describe Motivations of Decisions
      • Structure and Interpretation of Computer Programs
        • Declarative and Imperative Knowledge
    • Articles
      • Two ways of constructing a software design
  • Design
    • Books
      • The Art of Unix Programming
        • The SPOT Rule
        • Rule of Clarity: Clarity is better than cleverness
      • Design Patterns
      • Agile Software Development, Principles, Patterns, and Practices
      • Patterns of Enterprise Application Architecture
      • Refactoring: Improving the Design of Existing Code
  • General
    • Books
      • The Pragmatic Programmer: From Journeyman to Master
        • Don't Repeat Yourself
      • Code Complete
      • Computer Systems: A Programmer's Perspective
  • Unit Test
    • Books
      • Test Driven Development: By Example
      • Working effectively with legacy code
  • Database
    • Books
      • Use The Index, Luke
    • Articles
      • Finding and Extracting SQLServer deadlock information using Extended Events
  • Troubleshooting
    • Debugging
      • First Chance Exception
      • Symbol Files
      • Visual Studio Debugging Tricks and Tips
        • Trace Point and Conditional Break Point
        • Remote Debugging
        • Postmortem Debugging of Dump Files
        • Use DotPeek as Symbol Server
        • Use Resharper to Generate Symbol Files
        • Learn Productivity Tips and Tricks for the Debugger in Visual Studio
        • 7 lesser known hacks for debugging in Visual Studio
        • View Threads and Tasks using the Parallel Stacks Window
        • How to navigate to source code of a 3rd party library using Resharper
        • Show Parameter Values in Call Stack Window
      • WinDbg
      • Windows Debugging and Troubleshooting
      • Mysteries of Memory Management Revealed,with Mark Russinovich
      • Malware Hunting with the Sysinternals Tools
    • Books
      • Advanced Windows Debugging
      • Advanced .NET Debugging
    • Tools
      • DotNet Decompilers
      • Fiddler
        • Configure Fiddler to Decrypt HTTPS Traffic
        • How to monitor web requests from localhost to localhost using Fiddler
      • WireShark
      • System Internals
        • Handle
        • ProcessMonitor
        • ProcessExp
        • RAMMap
      • PostMan
        • Postman AWS Signature Auth
      • Asmspy
  • CSharp
    • Books
      • Advanced .NET Debugging
      • CLR via C#
      • C# in Depth
    • Articles
      • Async/Await
        • There is no thread for Async I/O
        • Async/Await - Best Practices in Asynchronous Programming
      • Rethrow Exception
      • Different effects of bindingRedirect
      • About Messages and Message Queues
      • Directory.Build.props
      • Memory Limits in a .NET Process
      • Prefer Timespan
      • Document Outline View
  • Practical Git via GitExtensions
  • Misc
    • Books
    • Articles
      • Floating Point Accuracy
      • The Absolute Minimum about Unicode
      • Postfix/Prefix increment operator
      • How A Typo Screwed Up One Of History's Worst Video Games
  • UI/UX
    • Books
      • About Face: The Essentials of Interaction Design
  • Front End
    • Books
      • Stylin’ with CSS: A Designer’s Guide
    • Articles
      • Introduction to Basic CSS Selectors
      • How Browser Works
  • Productivity
    • Tools
      • Everything
      • ConEmu
      • Vim
      • Bash
        • Navigating Bash History with Ctrl+R
      • Customise Your Powershell
    • Books
      • Mastering Regular Expression
    • Text-Editing Keyboard Shortcuts
  • System
    • Windows Message Queue
    • Mysteries of Memory Management Revealed,with Mark Russinovich
Powered by GitBook
On this page

Was this helpful?

  1. Productivity
  2. Tools
  3. Bash

Navigating Bash History with Ctrl+R

Bash (and Git Bash) records the history of all the commands you have typed and puts it in ~/.bash_history. It is really useful to look back at the history to use the same commands again or edit them slightly. You can press the up arrow to go through your history but it can take a really long time to find what you're looking for. So instead, try Ctrl + r.

To do this: first press Ctrl + r, then start typing the command or any part of the command that you are looking for. You'll see an autocomplete of a past command at your prompt. If you keep typing, you'll get more specific options appear. You can also press Ctrl + r again as many times as you want to, this goes back in your history to the previous matching command each time.

Once you see a command you like, you can either run it by pressing return, or start editing it by pressing arrows or other movement keys.

To retain history across sessions, you need to add the PROMPT_COMMAND='history -a ~/.bash_history' to your .bash_profile then close and reopen all bash sessions

 echo "PROMPT_COMMAND='history -a ~/.bash_history'" >> ~/.bash_profile
PreviousBashNextCustomise Your Powershell

Last updated 6 years ago

Was this helpful?