Ctrl r
Everyone sharing their Ctrl+R tips, here's my Control+R question:
How does scope work? Some command history only seems to exist in certain tabs.
Also sometimes I Ctrl+R in a tab then the command is there but I forget I need a different one first, so I ctrl+c but the next time I search for that original command somehow it doesn't exist anymore.
I'm using the default terminal on Nobara (fedora based).
history | grep then !cmd_number
If only you had a little picture to click on...
I used to be like this but people seriously. CTRL+R
Do it. Don't make this one of those things you've heard about and just never got around to trying. Open your terminal right now and CTRL+R and type any part of the command you did before. If the command you want is not showing first just hit CTRL+R again to go to the next one back.
DO IT.
Edit: I did learn from this thread today though that ZSH has it set to where you can just type part of what you're looking for then hit up to do the same thing. Neat!
Holy shit. I just tried it. ctrl+r
is a revelation! How the fuck did I not know about this?
You can empower Ctrl+r event more by using fzf. After I started using it, I can't imagine going back to without it.
WHAT THE FUCJ IS THIS SORCERY BRO I'VE BEEN USING LINUX FOR AGES AND NEVER KNEW THIS BROOOOOOOOOO
Edit: I did learn from this thread today though that ZSH has it set to where you can just type part of what you’re looking for then hit up to do the same thing. Neat!
Fish too, it's fantastic.
history | grep [the thing]
CTRL+R [the thing]
please i beg you
with grep I see all the alternatives, Ctl+R just shows me one
You can press up
Combine ctrl+R with fzf and get the best of both worlds
For me ctrl-r
is faster most of the time, history | grep [command]
is better if I can't easily pattern match (don't remember it exactly, using several flag variations, etc.). they're both good tools.
Ppsshh. Not lazy enough. Create that in a script and call it "hgrep" and drop it into path.
Why not just use an alias?
Brilliant
i was doing cat ~/.bash_history | grep thing
which is stupid so i started doing grep "thing" ~/.bash_history
now you're telling me i should do history | grep thing
i can't win
Some would call the former command cat abuse.
In short, unless you want the contents of a file printed to stdout (or multiple files concatenated), the command can probably be written without cat
, instead using the filename as an argument (grep pattern file
) or IO redirection (cmd < file
).
Stylistics and readability are another thing though.
Ctrl+R
https://atuin.sh/ Does all that and a lot more, like showing if the command succeeded and which directory it was run in
I'm shocked how far I had to scroll down before it was mentioned, I was getting scared I would have to say it lol
This but with FZF and ag
This is what I love about Linux - always learning new things!
What the fuck!? How am I only learning this now, after years of linux as daily driver?!
Just checking, because I learnt to type before I worked this out, and because surely someone reading doesn't know: press tab. Bash will fill in file names from your current directory.
E.g. say you have files fred1file, fred2file, jim.
Type f then press tab, it will fill to "fred". Then press 2 and press tab again and it will fill the full "fred2file".
Have a play, it works in heaps of situations.
Congratulations! I remember where I was when I first learned it (in a noisy server room at the back of a machine shop).
Now pair it with FZF for fuzzy finding -- it's surprisingly easy to set up, just following any guide. It's insanely useful. I find myself even doing things like typing:
$ xinput --disable $(xinput --list | grep -i touchpad | grep 'id=[0-9]\+' -o | cut -d= -f2) # Disable synaptic touchpad trackpad pointer
commands with these like comments on the ends as sort of "tags" so I can ctrl+r search for them later. Yes, I know I could just use a named function, but this is like the step just before that--before I know if I'll be issuing the same command all the time, or just for the next couple weeks. (This one was from when I was resting my notebook on my laptop.)
I like this; I have a lot of commands that I don't use often enough to justify an alias, but still need to rerun all the time. thanks!
Shit is usually a pain in the ass. The challenge is divining how much of a pain in the ass something has to be that someone else might have made a solution for it.
I didn't know you could ctrl+shift+c to copy in the terminal until a month ago when my linux n00b wife said "there has to be a better way to do this. I've been right clicking to copy for 10 years.
And ctrl + shift + v to paste, just in case
If that doesn't work, Shift + Insert.
Ctrl+c to copy, Ctrl+v to paste, Ctrl+z to undo last change (chain it multiple times to reverse time) hopes this helps, ctrl+tab also changes applications on macos and Linux to my knowledge. If you know anymore let's put them together
most DE's have a thing where you can paste highlighted text using the middle mouse button
Basado
No es común ver hispanohablantes en Lemmy, ¿de qué país eres?
What, and type 'ls' again?
linuxmemes
Hint: :q!
Sister communities:
Community rules (click to expand)
1. Follow the site-wide rules
- Instance-wide TOS: https://legal.lemmy.world/tos/
- Lemmy code of conduct: https://join-lemmy.org/docs/code_of_conduct.html
2. Be civil
- Understand the difference between a joke and an insult.
- Do not harrass or attack users for any reason. This includes using blanket terms, like "every user of thing".
- Don't get baited into back-and-forth insults. We are not animals.
- Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
- Bigotry will not be tolerated.
3. Post Linux-related content
- Including Unix and BSD.
- Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of
sudo
in Windows. - No porn, no politics, no trolling or ragebaiting.
4. No recent reposts
- Everybody uses Arch btw, can't quit Vim, <loves/tolerates/hates> systemd, and wants to interject for a moment. You can stop now.
5. 🇬🇧 Language/язык/Sprache
- This is primarily an English-speaking community. 🇬🇧🇦🇺🇺🇸
- Comments written in other languages are allowed.
- The substance of a post should be comprehensible for people who only speak English.
- Titles and post bodies written in other languages will be allowed, but only as long as the above rule is observed.
6. (NEW!) Regarding public figures
We all have our opinions, and certain public figures can be divisive. Keep in mind that this is a community for memes and light-hearted fun, not for airing grievances or leveling accusations. - Keep discussions polite and free of disparagement.
- We are never in possession of all of the facts. Defamatory comments will not be tolerated.
- Discussions that get too heated will be locked and offending comments removed.
Please report posts and comments that break these rules!
Important: never execute code or follow advice that you don't understand or can't verify, especially here. The word of the day is credibility. This is a meme community -- even the most helpful comments might just be shitposts that can damage your system. Be aware, be smart, don't remove France.