siempre lo hago
siempre lo hago
siempre lo hago
Guilty!
Nah just save all your commands in a text file on the desktop then make an alias to open it in nano so you just have to type "com". Works for dumb ol me
Why not just make the alias command cat the file instead?
Edit: I wrote grep instead of cat
Ah crap how did I set my battery charge interval again?
history | grep battery
history | grep bios
history | grep sudo smbios
Ah! There you are you little shit!
edit to add: Actually, I think the last time I did this I remembered some numbers I set it to before. So it worked well with something like "history | grep 75" even though there were a bunch of results.
Is there a good way to do this when you use a lot of terminal tabs and aren't sure which tab you used for the command you're looking for?
!ssh
run the last command that started with ssh
I... Well... Thank you !
Or just use fish shell. Rarely need ctrl+r anymore.
I'm familiar with fish shell, but what specifically makes you like it?
fellow fish user, I just like its autocomplete and how I can just type 'help' and an interactive HTML page opens up where I can look stuff, and fish_config does the same except with settings and themes
history 500 | grep snippet of command
I see everyone posting about Ctrl+R, here's a couple more useful CLI shortcuts you might enjoy:
cd - (change directory to $OLDPWD usually the previous directory)
git checkout - (similarly checkout the previous branch)
Ctrl+A (return caret to beginning of command, great when you forgot a positional argument and you were almost done typing the command)
Ctrl+E (similar to Ctrl+A but move to the end of the command)
Ctrl+A, Ctrl+E
Many more basic Emacs keybindings work, actually! Including C-f, C-b, C-p and C-n (if you prefer them over arrow keys) as well as M-f and M-b to move by words, C-k, M-d and C-y for killing/yanking (but not M-w) and C-SPC, C-w, C-x C-x for region manipulation (tested in Bash and ZSH)
I see so many people loving on atuin in the comments but I just tried it and don't get it. It seems so much worse than the built in search. I guess it's not for me.
I've been using it for a few months, and so far it's not as good as just regular old command history. I think any benefit might be for really, really old commands, or commands happening in a specific location. So, I'm going to keep using it to see if it helps then. But, so far it's a massive downgrade.
Atuin Magic Shell History is pretty good.
zsh-history-substring-search
I lazily type part of the thing I want like "sys" and then ctrl+⬆️/⬇️ and sudo systemctl start libvirtd
etc. appear like magic.
It's too early to call me out like that.
More like ⬆️⬆️⬆️⬆️⬆️⬆️ mother fucker ⬇️
Ctrl r
The worst is when you remember doing something before, but don't remember enough details to be able to effectively search for it.
Although, even then, I'm not going to just mindlessly hit "up". Last time it happened I fed my command history through grep and removed all the things that I knew the command wasn't. Just removing "ls" and "cd" from your history cuts the number of commands down by 80% or something.
Check out the fzf shell bindings. Reverse history search with fuzzy matching is one of the features.
Almost, ctrl+R, ⬆️⬆️⬆️⬆️⬆️⬆️⬆️
You know the one command I hate? CTL vs CTRL. There is no damned consistency I can see. Is it systemctl reboot or systemctrl reboot?
i've literally never seen 'systemctrl'? it's always ctl for the command-line utilities
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!
CTRL+R + FZF is the goat. You just need to vaguely remember the command and you'll find it.
This changed my life when I discovered it. Also using ag
as alternative to ack.
FZF Vim plugin is also gold!
Holy shit. I just tried it. ctrl+r
is a revelation! How the fuck did I not know about this?
If you want to level up ctrl-r, upgrade to Atuin: https://atuin.sh/
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.
Ctrl+R
What the fuck!? How am I only learning this now, after years of linux as daily driver?!
Same.
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.
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:
shell
$ 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.)
Use mcfly and it will be even better.
https://atuin.sh/ Does all that and a lot more, like showing if the command succeeded and which directory it was run in
This but with FZF and ag
I'm not going to say how long I used linux before learning this. It isn't "this many days old", but it may as well be.
I have 7 headless linux boxes running.
Hey! I've seen you before! You're the unhinged jackass noticer!
...i looked in your comment history for too long to figure out why though. https://lemmy.world/comment/18001123
Wait till you learn about !?
.
^r is superior, though.
This is what I love about Linux - always learning new things!
Even quicker with zsh or atuin: write the first few letters then arrow up to cycle through all matches
Even quicker with fish: Write the first few letters then it auto-suggests the last-run command matching that prefix (and then you can still arrow up to cycle through all matches).
(There is also a zsh plugin for that, called zsh-autosuggestions.)
I main ZSH and I've been CTRL+R'ing for years damn here I am a fool
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
I like to imagine someone added it in for their own personal use and told nobody because surely they are the only one.
history | grep then !cmd_number
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).
This actually doesn't depend on your terminal but on the shell running inside it. Bash is the default on most distros. I have also frequently had this issue. There might be config to fix it.
I switched to fish instead of bash, and now I use fzf and the https://github.com/PatrickF1/fzf.fish plugin and it works GREAT. There might be a similar thing for bash, I don't know.
That looks awesome! Thanks for the rabbit hole 😅
As far as I remember, there is a bash setting that controls whether the command history is written immediately after execution (in which case it is immediately available on all tabs/windows of the console) or after closing the session (in which case it will be available next time/potentially lost if the window is forcibly closed etc).
The default is the second one as far as I remember.
That said, I had changed to a more powerful one in zsh years ago, so it's been a while...
Thanks, I worked it out. Not a setting as such, but you can use PROMPT_COMMAND to run an action to insert into history each time a prompt is run, as described here.
Though I have started down a rabbit hole of looking at other options for the shell.
I love this one but is the gif moving at 0.5 frames a second or is it just me
For me, it looks normal (about 8 frames a second, probably).
Normal for me. Thanks for pointing out it was a gif. I never realize they're gifs because I have to "open in external" for them to actually move.
It works fine for me if I click on it but the embedded one is stuttering.
history | grep [the thing]
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.
What, and type 'ls' again?
I thought command line users like typing things. I avoid typing where possible, and dont use the command line on Linux.
Part of the reason for a command line is being able to reproduce commands exactly. Going back through the command history is an important part of that.
For a while I was using a VPN where the connections we all via command line. I loved it, because once you type it, it's just up up up to find that location again and swap around.
Now I have to use the mouse and click like a damn fool!
In my first professional programming job writing custom software for clients in 1995, one of our standard sales pitches to clients was the idea that a GUI-based application would do away with the need for command prompts. This was always met with applause and great rejoicing. It's kind of remarkable that command prompts are still going strong thirty years later. I'm sure nobody would appreciate having this phenomenon compared to the Amish so I won't do it. But I think it's pretty cool that the Amish are still around doing their thing.
GUI is great, unless you want to automate something.. Then you either want a CLI or API
People do not just point and nod. Using words and not just guestures makes life easier in many, but not all situations.
A GUI makes sense if you want things to be approachable. A CLI makes sense, if you want things to be well customizable.
E.g. compare LaTeX script with setting formatting in an office program. Yes i see directly how the formatting is. And if a good Formatting standard is set, it can be used quite well nowadays. But if just want to put one Paragraph differently in order to fit a picture or table or something then things quickly get messy.
I just mapped page-up to search (and you can too)
But, why? Ctrl-R is right there.
history | grep ‘part of the command I remember’
Everytime I use ffmpeg...
Ha... That as if I would ever remember the part of the tool instead of the fact what it did 🤣
Also: Ctrl+r then type the part of the command you remember.
Report post
Report reason: ⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️"There it is" I'm in this picture and I don't like it
just use atuin
.
ese lo tengo, es muy bueno
Atuin is so good, especially with multiple machines. I just would love more comp. time options to disable the dot dotfiles feature etc.
Basado
No es común ver hispanohablantes en Lemmy, ¿de qué país eres?
De Venezuela, no viene mal q empiecen a llegar contenido en español
If only you had a little picture to click on...
Set -o vi
History | grep wtf was that command again?
I type the first few letters and use up arrow, or !start of command name
Doesn't work on half the machines I use,and I am too lazy to find the setting/plugin to make it work.
$ cat .inputrc $include /etc/inputrc "\e[A": history-search-backward "\e[B": history-search-forward
This is why I use fish, it's weird and not posix compliant, but its autocomplete and history stuff saves so much time it's worth it
Your readline config sucks because the default sucks.
Add this to your .inputrc:
"\e[A": history-search-backward "\e[B": history-search-forward
god I fucking love Linux (not a Linux thing) but I still fucking love Linux
I mean that's what it's there for
grep -i "whatever" .bash_history
you really should just ctrl + r and type and then ctrl + r to goto the next one back.
Huh. I didn't know that one. It's much more practical. Thanks for teaching me something today.
Alabado sea El Omnissiah.
Que paso que hay tanto comentario en Castellano? Pensé que eramos pocos los hispanohablantes
Fuck that hits so hard.