174
linuxxx
7y

I just discovered ctrl+r in the Linux terminal.

Mother of god this fucker speeds up my workflow!

A massive amount of kudos to the person who made this 😍

Comments
  • 13
    What does it do?
  • 31
    @ewpratten It searches the history of entered commands.
  • 9
    Thanks, now I have 'discovered' it as well 😅
  • 28
    Do you use zsh? If not, that's the real game changer. And oh-my-zsh has tons of really good plugins and themes
  • 23
  • 6
    Yeah. Search in bash_history :p

    With zsh & tsch you'd type a bit then hit arrow up & down.

    With fish shell it searches as you type.. :)
  • 3
    Wow, I never knew about that. Thanks!
  • 0
    I use it all the fucking time it's awesome! 😍
  • 3
    @linuxxx I thought you had Linux classes at university? 🤔
  • 9
    @linuxxx is such a nub 😄
  • 3
    Whoa! There's a search command? I used to end up typing a bunch of times the same thing cause I feel so bored pressing the up key and wait
  • 0
    It works on putty, wooh that is useful... Recovering commands that I need from our admin login on Mondays.

    A lot of people login with it during the week so pressing Up to find the command would take forever...
  • 1
    If you want to boost your Workflow, try zsh with the grml config.
  • 2
    Omfg YOU ARE AMAZING best not rant ever!
  • 1
    Oh wut, most of the time I used history | grep. This is way more simple
  • 1
    @MatiasConTilde Thanks! Will install right away when I get home :)
  • 6
    1. I hate zsh.
    2. I love bash.
    3. I love fzf.

    With FZF, Ctrl-R fuzzy-finds through history... and Ctrl-T for all files recursively in current directory.

    https://github.com/junegunn/fzf

    Can also be used in Vim for various search tasks. You can actually pipe any set through it for filtering.
  • 6
    I really am shocked that so many ppl don't know about this. We are we not promoting shit like this?
    PS. @linuxxx you are a bit of a noob 😂
  • 2
    @bittersweet That sounds great
  • 2
    @linuxxx fucking noob 😂

    And if you dont find what you want with the given input press again ctrl + r , it will show more results
  • 1
    Bashhub is really nice for this too.
  • 1
    @WorstVarNames Oh so if you don't know everything about something you're a noob at it right away?
  • 2
    Perhaps I should do a rant a week containing useful advice/tips for Ruby/Linux/Windows/OSX? 😋
  • 1
    @Root - yes please share your gems.
  • 0
    @Jilano ha! Totally unintended!
  • 0
    Old news for me this. But I have no case for it. Think it is faster with the other shell buildins like ”!!” or ”!command:p”. all these is faster workflow for me then that search
  • 0
    You should check out bashhub for commands history power. It’s great.

    Not recommended for work though if you’re typing in sensitive information. I use it only at home.
  • 0
    Didn't know about it, thanks for sharing I was in need of something like that.
  • 1
    @nik123

    I hate zsh because I have bash profile since the mid 90's, which is about 10k lines long or so, and totally utterly incompatible with zsh. Doesn't even find matches for my hats, and I like my hats^.

    So if I pretend to hate zsh, I'll never have to worry about porting it.
  • 0
    @bittersweet what are you talking about
    There are scripts that convert bash histroy to zsh just fine
  • 2
    @Kimmax

    He's not talking about history. He's talking about shell config. The syntax is totally different between bash and zsh.
  • 1
    This is my new best thing WTF
  • 1
    @lotd I also use fish and I think it's amazing.
  • 2
    @bittersweet I think fzf is the best discovery I've made in a long time :)

    @Linuxxx nice that you found out about CTRL-R, I'm using it every day. I wouldn't be able to live without it, since my teacher introduced me to it 6 months ago :)
  • 3
    I knew something before linuxxx did :O
    I feel special :p
  • 0
    Good to know! I always used "history | grep foobar" to search
  • 0
    @f7u12 you should try thefuck. Just type fuck after you mistyped something or forgot sudo and magic happens

    https://github.com/nvbn/thefuck
  • 2
    @Drudge me too! I just learned that if you press 'enter ~ .' in a row you can leave broken ssh sessions. Such a fucking reliever!!
  • 0
    @ThatDude what the actual? :D
  • 0
    @linuxxx I was playing with you :)
  • 0
    @bahua that makes sense
  • 1
  • 0
    @Root Another username change. Aah!
  • 0
    There's also forward search, default keybinding is ctrl + S (yet you might have to tweak your system to get it). Incredible useful if you hit R a few times too often and fly past your intended line.
  • 0
    I feel pretty stupid now... I always used:
    cat ~/.bash_history | grep [command keyword]
    :/
  • 4
    @Sjoerd Shame! You should have at least been using `history | grep command`. Or the arrow-up key ;P

    On a more serious manner: Ignorance is not stupidity. A lot of those things somebody has to show you. That's also why I like pairing up with other developers and ask them "how did you do x?"

    Otherwise I'd still be grepping files even though there is silversearcher-ag, be lost within huge json even though there is jq, running vm even though there is docker; the list goes on.

    I just had the luck that my mentor showed me reverse search 7 years ago.

    Only rarely do I have an awesome idea myself, like: Wouldn't it be awesome to have a tool that jumps into the most relevant folder based on directory name and how often I cd into it -- only to then discover that it already exists: autojump.

    Yet as long as you are prepared to integrate productivity boost into your workflow, don't feel bad about it. Your solution did get the job done, now you know a more efficient way to do the same thing.
  • 1
    And you guys should also put comments after your frequently used commands so that it's easier to get back to by just searching for the comment that you just put!

    For instance:

    ssh acceptance.node.com #ACK1

    And you can just get back to this command by CTRL+R and ACK1
  • 0
  • 0
  • 1
    @AlexDeLarge Same reason I pretend to hate all people except a select few. Saves me from having to change my config files.
Add Comment