4 ms·
using `Ctrl + r` in your shell, I just hope someone reading this doesn't know it yet :-)
by mathieubordere 7y ago
using `Ctrl + r` in your shell, I just hope someone reading this doesn't know it yet :-)
- seisvelas 7y agoI worked for years as a sysadmin grepping through history because I'm just learning this from you. Thanks!
- mathieubordere 7y agoThat is heart-warming news!
- F147H34D 7y agoI had a coworker who was having some issues. I chuckled when he had an alias for history | grep when I was checking out his env
- CGamesPlay 7y agoIs that why his Mercurial wasn’t working?
- capableweb 7y agoTo be fair, I also have that alias and use CTRL+R. They are useful for different scenarios. CTRL+R when I know what command I'm looking for, but can't remember the full one. `history | grep -i $TERM` when I remember some part of the command, but not exactly sure. With that, I get a list of possible candidates to choose from, instead of having to do CTRL+R repeatedly to find the command I was looking for.
- praptak 7y agoBuilding on this, infinite shell history. Google how to set it up for your shell.
- F147H34D 7y agoDid this years ago. I am very thankful I did. It has saved me a few times on cmd syntax. Seems like iptables is the one I always screw up. I recently started migrating the history across reinstalls.
- deleted 7y ago[deleted]
- KORraN 7y agoWow, thanks! I knew about ## arrow up "\e[A":history-search-backward ## arrow down "\e[B":history-search-forward but it works only for beginning of the line. CTRL + R shows results with keyword anywhere within the line and pressing it again shows next result. CTRL + Shift + R goes back one result.
- weaksauce 7y agoZpresto has a zsh plugin thing that you can enable to get partial substring search with up/down arrow and color highlighting for the match. Really useful and one of my favorite features
- lunchables 7y agoI just use ctrl-p/n for back/forward in history? Does that not work pretty much everywhere?
- foxish 7y agoTo anyone that has use for this, I also recommend trying the fish shell. It takes some getting used to at first but the sheer time save I realize with just autocomplete is monumental!
- wtmt 7y agoCan you add more details on autocomplete (and anything else) on why someone should try it and/or how you’ve benefited from it compared to the common bash that’s around on systems?
- sowbug 7y agoIf you like this, you'll also like pushd/popd. Example: $ cd ~/src/app/foo/bar/baz $ pushd /etc/qux/quux/quuz/corge/grault/garply/waldo $ popd $ pwd /home/you/src/app/foo/bar/baz It's a stack of directories. You pushd the current directory on to the stack and cd to a new directory all in a single command, then you popd back to the previous directory (i.e., the one on the top of the stack). It's useful if you're jumping all over the filesystem to do work, or if someone interrupts you and you want to cd somewhere to show them the contents of a file without losing your own context.
- abathur 7y agoIt's not as robust as pushd/popd, and it may vary from shell to shell, but at least in bash you can also use "cd -" to change to the previous directory.
- jcelerier 7y agopro tip : you can also do the same with git : "git checkout -" will bring you to the previous commit you were on
- tryptophan 7y agoOr you could try autojump. It tracks where you have cd and then you can jump to locations from past history using fuzzy matching. so if you cd to /usr/home/me/tacos once, from then on you can just > j taco and it will cd to that directory. Saves so much time! Instead of typing out /etc/nginx you can just type "j e ng" and it will jump there.
- dfinninger 7y agoMy favorite is C-x C-e in your shell. Bonus points for having EDITOR=vim in your env. I use this so many times in a day. It’ll copy the text in your current command line into your $EDITOR. Saving and quitting your editor will put the modified text back into your command line. Never fear long commands again!
- diego_moita 7y ago> I just hope someone reading this doesn't know it yet :-) I didn't, thank you. It works both in bash and powershell.