Infuriatingly that would omit things like unit test runners from the history in case they don't pass. As a developer I tend to re-run failed commands quite often, not sure how widely that applies, though.
It was quite a while before I realised that was possible.
Then not long after starting to use it, that I got fed up and just started opening up the history file and searching in it.
Holy cow!! I didn’t know that.
I have been using history > history.txt to find “that one command for that one thing” I only need once every other month or so. Thanks, now I can just do that.
https://github.com/atuinsh/atuin is a great tool to manage and search your shell history. I especially enjoy it being able to search commands based on the working directory I was in when I ran them.
It also has more features (which I don't use) to manage dotfiles and sync shell history across hosts/devices.
I was going to talk about it too ! Even though I'm on fish (which helps a lot with history search) atuin really changed my habits and made my life easier !
yeah I ONLY just recently switched to fish after using zsh and oh my zsh for so long - pretty much since first starting linux cause I once saw someone using it on unixporn and I thought "that's cool"
when I switched to NixOS zsh with all the plugins was a total slog. switched to fish and it just HAS everything that zsh/oh my zsh and the various plugins had but baked in.
so yeah in Fish it's just starting to type something and hoping it's still in the history.
That's when you start spamming Page Up/Down, Home, End, and / to search within less. Usually seeing various commands jogs my memory, especially when they are grep commands searching for one I use often enough to be useful but infrequently enough to not remember off the top of my head.
Ah. Well. I can not be blameless on this. I also probably use cat unnecessarily still. But less so with grep these days. I'm getting better... I swear!
Wow this is really validating for me to read. I’ve been using Linux for a few years but I’m definitely not a computer expert and am intimidated by the command line.
I’ve always felt like googling every command and arrowing up to find an old entry rather than just googling it again marked me as a fake Linux user, not a real one.
Lol don't feel bad, I can do advanced crazy shit with Linux like pivoting the running OS into RAM so I can unmount the boot drive to do whatever without ever rebooting
But I still [Web Search] commands a shit ton of the time LMAO
Ok. Show me the pivot trick. I usually mess with the boot disk through a reboot, but it's been a while (resized the root to clear space for a part) and it was not without anxiety. Interactive work while the host is up is way better.
So you build a chroot in a ramdisk, restart everything active in there and then run the pivot-root that I've seen in the middle of every boot I've ever watched. And that's it?
It's got a back-out in every stage too, maybe. Fantastic. I'll add that to the list for Science Projects I need to do.
That's super unkind and incorrect. IE was a trash software that was widely available because MS was trying to extend their monopoly into new areas.
Even if it's not your taste, bash is a mature, stable FLOSS package with wide community support. The reason it is so common is due to it's positive attributes, not because there is a plot to make it the only choice available to you.
It's good to know how to do things in bash, since you're going to encounter it pretty often. But, that doesn't mean you shouldn't customize your shell on the machine(s) you use most often. Why stick with the default when there are better options? You're just hobbling yourself.
Fish once again undefeated. If I want to find that weird image magick command I used earlier with foo.png in it I just type foo.png, hit up and its usually the first one. It doesnt matter where foo.png occurs in the command, fish will find it.
Aliasing cat or any other ubiquitous shell utility to a replacement is a mistake. Garuda did this, and it was driving me crazy why cat was giving me errors. Turns out that they had aliased bat to cat, and since bat is a different program, it didn't work in exactly the same way, and an update had introduced some unexpected behavior.
Drop-in replacements are dumb. Just learn to use a different command.
If you are me, there is no brain space for remembering new commands. I can already barely hold on to few dozens that I use often.
And occasionally when I need "that one that does that niche thing... how was it?" program - I just sit there sifting through logs for couple minutes.
Today it was od (tbh it's od almost half the time; not really the best name to memorize (I really need to make a note or something, so I stop forgetting it, lol))
Also, for this reason I went to great lengths to keep my ~/.zsh_history protected from being randomly deleted/overwritten by mistake, as it happened a couple of times. Currently it's sitting at around 30_000 lines, oldest command is 2 years old.
Not sure I understand the point of mcfly. zsh and fish have this functionality built in, where pressing Up with a command partially typed will give auto-completions to that partial match.
Yeah. I also use auto-completions for that. McFly does fuzzy finding and because it's a different separate db, for me it works better across many sessions to find commands I had just recently used in another session.
With ZSH there's something called "path-completion" that makes that even easier.
Say you want to go to "/usr/local/share/fonts" but that's too much to type out, you can instead type "cd /u/l/s/f" and hit tab. If every path element is unambiguous it will just expand it to "/usr/local/share/fonts". In this case though, "/u/l/" can expand to "/usr/local" or "/usr/lib" so when you hit tab it moves the cursor to just after the "l" to indicate it needs you to distinguish between "/usr/local/" and "/usr/lib". If you just type "o" and hit tab again, it will know that there's only one match for "/usr/lo" and expand that to "/usr/local/" Then there's only one match for "s" which is "share", and only one match for "f" which is "fonts".
That avoids the danger of executing a command with an asterisk wildcard.
Did I remember correctly what command sequence I last used that pattern with? Will my data be gone? Will I send a vulgar email to my boss? Who knows, let's find out!
I don't understand people who have the confidence to just blindly run the last matching command like that. Like, are you 100% sure that the last time you ran find was that one, not the one that piped to xargs rm?
At least with zsh you can tab to complete the !find and verify it's what you want before running it. And, AFAIK by default, the shell option hist_verify is set, so if you do just type !find and hit enter, it doesn't run the command, it loads the command into the editing buffer so you can look it over first. Maybe I just have a weak memory, but I really appreciate the footgun prevention. At worst I have to hit enter twice. At best, I save myself a lot of grief.
149 Comments
TabbsTheBat@pawb.social · 89 pts · 324d
I've been using
ctrl + Rmore now :3.. though I definitely used to ↑↑↑↑↑↑↑I_Am_Jacks_____@sh.itjust.works · 39 pts · 324d
check out fzf (install fzf and add (assuming bash)
eval "$(fzf --bash)"to your .bashrc) Makes ctrl+r a superpoweraquovie@lemmy.cafe · 5 pts · 324d
It's awesome until you want to put the cursor in a specific spot of a previous command.
But I still use fzf because while I used to do the above, fzf offered more advantage that made switching worth it.
TabbsTheBat@pawb.social · 3 pts · 324d
I'll try it if I don't forget it by the next time I have access to my PC lol :3
tyler@programming.dev · 21 pts · 324d
Ctrl + r with fzf and you’ll never go back.
sbeak@sopuli.xyz · 2 pts · 322d
Woah Ctrl R looks super cool, never knew that I could do that before…
lmmarsano@lemmynsfw.com · 55 pts · 324d
or documentation.
AmidFuror@fedia.io · 16 pts · 324d
To use ctrl-r I have to remember something about the command. To use up arrow I just have to know about how many commands ago I used it.
silasmariner@programming.dev · 8 pts · 324d
Not if you have fzf you don't: https://github.com/junegunn/fzf
Like an interactive fuzzy finding history. It's sick.
Auli@lemmy.ca · 2 pts · 323d
So how well you know which command it is of you won't recognize it when you see it..
B_DL@lemmynsfw.com · 48 pts · 324d
I knew there was an
In there somewhere
teletext@reddthat.com · 9 pts · 324d
inktvip@lemmy.dbzer0.com · 3 pts · 324d
ls .. enter ↑ enter ↑ enter
ulterno@programming.dev · 1 pts · 323d
You may consider using
watch lslord_ryvan@ttrpg.network · 1 pts · 317d
I do like that, thanks a lot ulterno!
emb@lemmy.world · 3 pts · 324d
Now I don't have to type that in again. Phew!
iamdefinitelyoverthirteen@lemmy.world · 43 pts · 324d
...until you press up one too many times and enter the same command but with a typo. Again.
AmidFuror@fedia.io · 10 pts · 324d
Been there, done that.
laserjet@lemmy.dbzer0.com · 5 pts · 323d
There is an option you can set in .zshrc or .bashrc which only includes lines that exit 0 (success)
antimidas@sopuli.xyz · 5 pts · 323d
Infuriatingly that would omit things like unit test runners from the history in case they don't pass. As a developer I tend to re-run failed commands quite often, not sure how widely that applies, though.
ulterno@programming.dev · 1 pts · 323d
Oh, stuff like
git diffandgit logwill end up being omitted pretty often.And a lot of times, the commands that end with piping into
lessAuli@lemmy.ca · 38 pts · 323d
Ctrl R
sol6_vi@lemmy.makearmy.io · 0 pts · 322d
holy fucking shit 🤌💪🤯❤️💯
aeharding@vger.social · 34 pts · 324d
The number of people who don’t reverse-I-search is too damn high
derpgon@programming.dev · 26 pts · 324d
CTRL+R for those unitiated
Everyday0764@lemmy.zip · 9 pts · 324d
reverse-i-search + fzf = <3
ulterno@programming.dev · 0 pts · 323d
It was quite a while before I realised that was possible.
Then not long after starting to use it, that I got fed up and just started opening up the history file and searching in it.
dropcase@lemmy.world · 3 pts · 323d
why not
history | grep -iand the search term?even if there are several, you can use ! and the command's line number to run it again
ulterno@programming.dev · 1 pts · 323d
historyis shell dependent.mvirts@lemmy.world · 29 pts · 324d
^r
veni_vedi_veni@lemmy.world · 13 pts · 324d
and whenever you forget to sudo:
sudo !!Gumus@lemmy.world · 8 pts · 324d
You need this: https://github.com/nvbn/thefuck
bandwidthcrisis@lemmy.world · 9 pts · 324d
Ctrl-r, l ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r, ctrl-r. To get ls.
2910000@lemmy.world · 7 pts · 324d
No way! I didn't know you could cycle through the results like that... awesome!
bandwidthcrisis@lemmy.world · 5 pts · 324d
It’s basically emacs incremental search.
Mad_Punda@feddit.org · 16 pts · 324d
I’ve probably done that for
lskilleronthecorner@lemmy.world · 14 pts · 324d
O(n) access, very efficient.
No, I do not care to share the value of n
yggstyle@lemmy.world · 14 pts · 324d
taptaptaptap.... taptaptaptap.... taptaptaptap taptaptaptap taptaptaptap
.... taptaptaptap
... tap ...
... shit I was on a different user when I typed it.
iamdefinitelyoverthirteen@lemmy.world · 8 pts · 324d
Or "shit, I did in tmux last time so I could close the terminal window."
salacious_coaster@infosec.pub · 12 pts · 324d
Relevant xkcd: https://xkcd.com/1168/
drkt@scribe.disroot.org · 9 pts · 324d
tar -xvf
but only because I had to look it up twice so now my brain has committed it to memory
I don't even know what it does
nutcase2690@lemmy.dbzer0.com · 4 pts · 324d
i just use unar (unarchive) nowadays, since that works with all file formats iirc
bitchkat@lemmy.world · 2 pts · 324d
Extract a tarball with verbose output from the specified file.
And learn how to use the 'z' option
jbrains@sh.itjust.works · 1 pts · 323d
You don't even need the hyphen!
Mind = blown.
Hammerheart@programming.dev · 7 pts · 323d
tar --helpprobable_possum@leminal.space · 3 pts · 324d
tar - h
IsoKiero@sopuli.xyz · 13 pts · 324d
Unfortunately that's not valid.
From man-page:
-h, --dereference follow symlinks; archive and dump the files they point toprobable_possum@leminal.space · 12 pts · 324d
Damn.
titanicx@lemmy.zip · 8 pts · 324d
Thanks, we all died.
probable_possum@leminal.space · 6 pts · 324d
:)
psud@aussie.zone · 1 pts · 322d
tar -jcvf archive.tbz ~/stuff/*
Of course I don't know the bomb had bzip2 on it.. I wonder if we can start with ls to see if there's anything to tar or untar
ezekielmudd@reddthat.com · 11 pts · 324d
Or, just type the command “history”, find the index number of the desired command, then type “! ”, then .
frezik@lemmy.blahaj.zone · 12 pts · 324d
That's way more mental effort than pressing up a bunch of times.
eager_eagle@lemmy.world · 8 pts · 324d
or Ctrl+R then search? I don't know why some people still bother with
historytbh.merc@sh.itjust.works · 3 pts · 324d
Because you can pipe history to grep.
snowe@programming.dev · 3 pts · 324d
with fzf you get better grep with fuzzy search
Sabata11792@ani.social · 2 pts · 324d
This is going to save me so much time pressing the up arrow.
irish_link@lemmy.world · 2 pts · 324d
Holy cow!! I didn’t know that. I have been using history > history.txt to find “that one command for that one thing” I only need once every other month or so. Thanks, now I can just do that.
lemmyng@piefed.ca · 2 pts · 324d
Ctrl-R if you know part of the command.
pcouy@lemmy.pierre-couy.fr · 9 pts · 324d
https://github.com/atuinsh/atuin is a great tool to manage and search your shell history. I especially enjoy it being able to search commands based on the working directory I was in when I ran them.
It also has more features (which I don't use) to manage dotfiles and sync shell history across hosts/devices.
nameisnotimportant@sh.itjust.works · 2 pts · 324d
I was going to talk about it too ! Even though I'm on fish (which helps a lot with history search) atuin really changed my habits and made my life easier !
freewheel@sh.itjust.works · 9 pts · 324d
Substring completion on ZSH. Type in a small part of the command you want to find and then press up.
entwine@programming.dev · 7 pts · 324d
bash supports this feature too btw
freewheel@sh.itjust.works · 2 pts · 324d
Added to my mental toolbox, thanks!
Edgarallenpwn@midwest.social · 9 pts · 323d
I typed it once, I'm not typing it again
flyingSock@feddit.org · 8 pts · 324d
also when they see this post
alecsargent@lemmy.zip · 7 pts · 324d
I always go past it because I go way to fast.
nous@programming.dev · 4 pts · 324d
I have more then once gave up on pressing up, hit ctrl + c to reset only to see the command I wanted briefly flash up as I am hitting ctrl + c
SexualPolytope@lemmy.sdf.org · 7 pts · 324d
In
fish, you can enter part of the command, and then press up to search for it. It's kinda awesome.rozodru@piefed.social · 5 pts · 324d
yeah I ONLY just recently switched to fish after using zsh and oh my zsh for so long - pretty much since first starting linux cause I once saw someone using it on unixporn and I thought "that's cool"
when I switched to NixOS zsh with all the plugins was a total slog. switched to fish and it just HAS everything that zsh/oh my zsh and the various plugins had but baked in.
so yeah in Fish it's just starting to type something and hoping it's still in the history.
RedSnt@feddit.dk · 2 pts · 322d
That's what I do in bash except for pressing up it's ctrl+r. FZF does the fuzzy finding for me. It's so convenient.
baltakatei@sopuli.xyz · 7 pts · 324d
$ history | grep 'gre[p]' | less -Smbp@lemmy.sdf.org · 4 pts · 324d
Does fuck all when you can't remember even a piece of the command lol
baltakatei@sopuli.xyz · 1 pts · 322d
That's when you start spamming Page Up/Down, Home, End, and
/to search withinless. Usually seeing various commands jogs my memory, especially when they aregrepcommands searching for one I use often enough to be useful but infrequently enough to not remember off the top of my head.Auli@lemmy.ca · 1 pts · 323d
Then how well you know which command it is when scrolling. At that point it's googleing how do I move a file or whatever your looking for.
FourThirteen@lemmy.world · 1 pts · 323d
This is the answer
UnfortunateShort@lemmy.world · 7 pts · 324d
fish has "directory-aware" autocomplete with inlay hints and a fantastic
historycommand. I do not suffer from such weaknessHammerheart@programming.dev · 7 pts · 323d
cat ~/.bash_history | grepechindod@programming.dev · 16 pts · 323d
Useless use of cat?
disobey2623@lemmy.dbzer0.com · 2 pts · 323d
You saying I can just skip cat in that command and it works?
x00z@lemmy.world · 9 pts · 323d
history | grep 'cat'ulterno@programming.dev · 0 pts · 323d
My output was empty for that command.
Guess why?
Because
historyonly gives the last few lines in my system.neox_@sh.itjust.works · 5 pts · 323d
disobey2623@lemmy.dbzer0.com · 4 pts · 323d
How did I not know this. Thank you!
oozynozh@sh.itjust.works · 2 pts · 323d
it's
grep STRING FILEto be preciseor
awk '/STRING/′ FILEif you prefer that for some reasonHammerheart@programming.dev · 2 pts · 322d
Yes, it was meant to be a self deprecating admission that I have used this unnecessarily verbose command.
echindod@programming.dev · 2 pts · 322d
Ah. Well. I can not be blameless on this. I also probably use cat unnecessarily still. But less so with grep these days. I'm getting better... I swear!
deacon@lemmy.world · 7 pts · 324d
Wow this is really validating for me to read. I’ve been using Linux for a few years but I’m definitely not a computer expert and am intimidated by the command line.
I’ve always felt like googling every command and arrowing up to find an old entry rather than just googling it again marked me as a fake Linux user, not a real one.
cm0002@lemmy.world · 7 pts · 324d
Lol don't feel bad, I can do advanced crazy shit with Linux like pivoting the running OS into RAM so I can unmount the boot drive to do whatever without ever rebooting
But I still [Web Search] commands a shit ton of the time LMAO
corsicanguppy@lemmy.ca · 2 pts · 324d
Ok. Show me the pivot trick. I usually mess with the boot disk through a reboot, but it's been a while (resized the root to clear space for a part) and it was not without anxiety. Interactive work while the host is up is way better.
cm0002@lemmy.world · 2 pts · 324d
Here's an overview https://lemmy.world/comment/11542288 though I never did get around to writing up an actual tutorial lol
corsicanguppy@lemmy.ca · 1 pts · 323d
So you build a chroot in a ramdisk, restart everything active in there and then run the pivot-root that I've seen in the middle of every boot I've ever watched. And that's it?
It's got a back-out in every stage too, maybe. Fantastic. I'll add that to the list for Science Projects I need to do.
Thanks!
zarkanian@sh.itjust.works · 4 pts · 324d
You can use Ctrl-R and Ctrl-Shift-R to search through your history instead of having to push up a bajillion times.
titanicx@lemmy.zip · 2 pts · 324d
I think that actually makes you a real Linux user...
Cevilia@lemmy.blahaj.zone · 1 pts · 323d
desmosthenes@lemmy.world · 6 pts · 324d
https://marko.tech/journal/fzf-ftw
remon@ani.social · 6 pts · 323d
You have to be a linux user to use the console now?
merc@sh.itjust.works · 6 pts · 324d
Too many people still use Bash.
humorlessrepost@lemmy.world · 2 pts · 324d
I like zsh on mac because pretty colors
Leonardo_da_Vinci@lemmy.world · 1 pts · 324d
Too many distributions still ship with Bash.
rtxn@lemmy.world · 13 pts · 323d
In the real world, the only thing better than perfect is standardized.
merc@sh.itjust.works · 2 pts · 324d
Yeah, true. But, it's easy to change.
Bash is the Internet Explorer of shells. It's great for installing a more useful shell.
laserjet@lemmy.dbzer0.com · 8 pts · 323d
That's super unkind and incorrect. IE was a trash software that was widely available because MS was trying to extend their monopoly into new areas.
Even if it's not your taste, bash is a mature, stable FLOSS package with wide community support. The reason it is so common is due to it's positive attributes, not because there is a plot to make it the only choice available to you.
calcopiritus@lemmy.world · 2 pts · 323d
Bash might be better than IE. But I think we can agree that it is no longer a good shell.
Its syntax is awful, and lacks many features that other shells have.
It is only so widely used because it is a de facto standard. If bash was created today, barely no one would us it.
pivot_root@lemmy.world · 2 pts · 323d
That's not true. Internet Explorer was fucking useless for scripting together things, unlike bash.
laserjet@lemmy.dbzer0.com · 4 pts · 323d
Internet Explorer shell expansion always trips me up.
Croquette@sh.itjust.works · 1 pts · 323d
What shell do you recommend?
merc@sh.itjust.works · 5 pts · 323d
I like zsh, but some people say great things about fish.
Auli@lemmy.ca · 2 pts · 323d
My problem with those is bash is always there and just works.
merc@sh.itjust.works · 3 pts · 323d
Yes, just like Internet Explorer.
It's good to know how to do things in bash, since you're going to encounter it pretty often. But, that doesn't mean you shouldn't customize your shell on the machine(s) you use most often. Why stick with the default when there are better options? You're just hobbling yourself.
iAvicenna@lemmy.world · 5 pts · 324d
history | grep then !cmd no
RedSnt@feddit.dk · 5 pts · 322d
I write part of the command then ctrl+r. Using FZF mind you. Such a great utility.
Olgratin_Magmatoe@slrpnk.net · 5 pts · 324d
grep | history [search term]Cevilia@lemmy.blahaj.zone · 7 pts · 324d
Olgratin_Magmatoe@slrpnk.net · 4 pts · 324d
Oops, but yes that's what I meant.
A_norny_mousse@feddit.org · 3 pts · 324d
alias hf='history|grep'Gobo@lemmy.world · 3 pts · 324d
I do this all the time for that one long command I use monthly like for cert renewals.
nullPointer@programming.dev · 4 pts · 324d
zsh tab completion also looks through history wich is pretty nice.
dreadbeef@lemmy.dbzer0.com · 4 pts · 322d
Fish once again undefeated. If I want to find that weird image magick command I used earlier with foo.png in it I just type
foo.png, hit up and its usually the first one. It doesnt matter where foo.png occurs in the command, fish will find it.janAkali@lemmy.sdf.org · 4 pts · 323d
history | fzfalias cat="bat --plain --theme=gruvbox-dark"zarkanian@sh.itjust.works · 7 pts · 323d
Aliasing
cator any other ubiquitous shell utility to a replacement is a mistake. Garuda did this, and it was driving me crazy whycatwas giving me errors. Turns out that they had aliasedbattocat, and sincebatis a different program, it didn't work in exactly the same way, and an update had introduced some unexpected behavior.Drop-in replacements are dumb. Just learn to use a different command.
janAkali@lemmy.sdf.org · 3 pts · 322d
I think it's ok to add this in a personal
.zshrc, not on a distro level:If it breaks something - I'd probably know why and can easily fix it by removing alias/calling cat directly.
Also, scripts almost always use bash or sh in shebang, not zsh. So it only triggers if I type
catin terminal.crater2150@feddit.org · 2 pts · 322d
Also, even zsh scripts don't read your .zshrc by default.
psud@aussie.zone · 2 pts · 322d
It's better to learn the new command, then it still works when you use a different machine that doesn't have your alias
janAkali@lemmy.sdf.org · 1 pts · 320d
If you are me, there is no brain space for remembering new commands. I can already barely hold on to few dozens that I use often. And occasionally when I need "that one that does that niche thing... how was it?" program - I just sit there sifting through logs for couple minutes.
Today it was
od(tbh it'sodalmost half the time; not really the best name to memorize (I really need to make a note or something, so I stop forgetting it, lol))Also, for this reason I went to great lengths to keep my
~/.zsh_historyprotected from being randomly deleted/overwritten by mistake, as it happened a couple of times. Currently it's sitting at around 30_000 lines, oldest command is 2 years old.MashedTech@lemmy.world · 4 pts · 323d
I just use mcfly
xoggy@programming.dev · 1 pts · 323d
Not sure I understand the point of mcfly. zsh and fish have this functionality built in, where pressing Up with a command partially typed will give auto-completions to that partial match.
MashedTech@lemmy.world · 1 pts · 322d
Yeah. I also use auto-completions for that. McFly does fuzzy finding and because it's a different separate db, for me it works better across many sessions to find commands I had just recently used in another session.
Tiberus@lemmy.dbzer0.com · 4 pts · 324d
I accidentally found out one day that I could use a wildcard operator in the terminal instead of a full file or folder name due to always doing this.
Will for example open my "Photo Examples" folder in the working directory or based on the path
merc@sh.itjust.works · 6 pts · 324d
With ZSH there's something called "path-completion" that makes that even easier.
Say you want to go to "/usr/local/share/fonts" but that's too much to type out, you can instead type "cd /u/l/s/f" and hit tab. If every path element is unambiguous it will just expand it to "/usr/local/share/fonts". In this case though, "/u/l/" can expand to "/usr/local" or "/usr/lib" so when you hit tab it moves the cursor to just after the "l" to indicate it needs you to distinguish between "/usr/local/" and "/usr/lib". If you just type "o" and hit tab again, it will know that there's only one match for "/usr/lo" and expand that to "/usr/local/" Then there's only one match for "s" which is "share", and only one match for "f" which is "fonts".
That avoids the danger of executing a command with an asterisk wildcard.
snowe@programming.dev · 1 pts · 324d
works in fish shell as well.
merc@sh.itjust.works · 1 pts · 324d
TheOakTree@lemmy.zip · 3 pts · 324d
This only works until you grow an addiction to making pho at home and start documenting your progress.
JasonDJ@lemmy.zip · 3 pts · 324d
You can use
||between two commands as well. If the first command returns exit code != 0, the second command will run.I.e.
which ansible || pip install ansible.merc@sh.itjust.works · 4 pts · 324d
Or && for if you only want the second command to run if the first command succeeded.
DarkAri@lemmy.blahaj.zone · 3 pts · 324d
cd /
sudo rm -rf *
Basically the Linux version of deleting system32 but idk I'm not a super Linux nerd yet.
bandwidthcrisis@lemmy.world · 5 pts · 324d
The fun thing is that you can create a file named "-rf *" and hope an admin tried to delete it!
clashorcrashman@lemmy.zip · 4 pts · 324d
...Yeah, you got me.
T156@lemmy.world · 3 pts · 324d
Being able to just enter a partial command, and hit [up] to jump to prior commands that started in the same way in zsh is a godsend.
Entitle9294@lemmy.world · 2 pts · 324d
If you ever have to go back to bash, it supports it as well. In my bashrc:
That's ctrl-p, but I'm sure the up arrow is possible too.
bss03@infosec.pub · 1 pts · 323d
I use vim keybindings and have
ESC,/to do a reverse command search.titanicx@lemmy.zip · 3 pts · 324d
I'm in this picture, and I didn't like it....
wewbull@feddit.uk · 3 pts · 324d
The one people see me doing that gets a "huh?" Is:
"Wait! What did you do?" "Oh. Do you not know about bang?"
UpperBroccoli@lemmy.blahaj.zone · 9 pts · 324d
I love the excitement of using !?
Did I remember correctly what command sequence I last used that pattern with? Will my data be gone? Will I send a vulgar email to my boss? Who knows, let's find out!
wewbull@feddit.uk · 1 pts · 323d
That's why you can add ":p" to the end just to print it.
merc@sh.itjust.works · 7 pts · 324d
I don't understand people who have the confidence to just blindly run the last matching command like that. Like, are you 100% sure that the last time you ran find was that one, not the one that piped to
xargs rm?At least with zsh you can tab to complete the
!findand verify it's what you want before running it. And, AFAIK by default, the shell optionhist_verifyis set, so if you do just type!findand hit enter, it doesn't run the command, it loads the command into the editing buffer so you can look it over first. Maybe I just have a weak memory, but I really appreciate the footgun prevention. At worst I have to hit enter twice. At best, I save myself a lot of grief.wewbull@feddit.uk · 1 pts · 323d
Normally the use case is
It's in my recent memory, but maybe there's been 10 or so commands of me fixing stuff in-between.
stealth_cookies@lemmy.world · 3 pts · 324d
This is why I like atuin, I can just press up and start typing part of the command and it will likely find it in my history.
merc@sh.itjust.works · 2 pts · 324d
You could already do that with just "Ctrl-R" but without atuin redrawing your screen.
RustyNova@lemmy.world · 3 pts · 324d
Oh come on! I at least type the beginning so that it filters the history
Laser@feddit.org · 2 pts · 324d
Linux Recall
Cevilia@lemmy.blahaj.zone · 2 pts · 323d
Endymion_Mallorn@kbin.melroy.org · 2 pts · 324d
I wish this wasn't so painfully true.
Quexotic@infosec.pub · 2 pts · 324d
Featherpad, copy, paste. Extra work, but you get a work log