abbadon420@sh.itjust.works to Ask Lemmy@lemmy.world · 15 天前Linux question: I like to browse using ls. Than when I find what I'm looking for, I would like to directly move there with cd without having to retype the path. Is there an elegant solution for that?message-squaremessage-square63linkfedilinkarrow-up1128file-text
arrow-up1128message-squareLinux question: I like to browse using ls. Than when I find what I'm looking for, I would like to directly move there with cd without having to retype the path. Is there an elegant solution for that?abbadon420@sh.itjust.works to Ask Lemmy@lemmy.world · 15 天前message-square63linkfedilinkfile-text
Maybe there is a tool that does that? Maybe I’m doing this all wrong and there is a different way I should browse?
minus-squareccunning@lemmy.worldlinkfedilinkarrow-up123·15 天前You mean something like this? ls /your/long/path/name cd !$
minus-squarevalar@lemmy.calinkfedilinkarrow-up112·edit-215 天前To add, !$ gets replaced with the last word from the previous command line !! Repeats the most recent command !-N Repeats the Nth previous command !string Repeats the most recent command that began with ‘string’
minus-squarevillage604@adultswim.fanlinkfedilinkEnglisharrow-up52·15 天前I just learned more about Linux than I did from my whole IT degree.
minus-square4am@lemmy.ziplinkfedilinkarrow-up20·edit-215 天前You learned more about shells than you knew. This stuff works on BSD and some UNIX systems too, you know
minus-squareBlue Label@lemmy.worldlinkfedilinkEnglisharrow-up1·13 天前I learned Ubuntu in uni decades ago, and I didn’t know those commands exist.
minus-squarem-p{3}@lemmy.calinkfedilinkarrow-up35·15 天前!! is the goat when you needed to run the last command using sudo
minus-squareHal@piefed.nzlinkfedilinkEnglisharrow-up10·15 天前Hot damn, and here’s me thinking thefuck was the way to do this.
minus-square4am@lemmy.ziplinkfedilinkarrow-up25·15 天前If !$ isn’t pronounced “ba-ching!” I’m quitting Linux
minus-square🌞 Alexander Daychilde 🌞@lemmy.worldlinkfedilinkEnglisharrow-up11·14 天前Better than “bang-ching” which sounds racist to me. lol
minus-squareSkaveRat@discuss.tchncs.delinkfedilinkarrow-up8·14 天前Great, now omarchy is going to adopt it
minus-squareMinnesotaGoddam@lemmy.worldlinkfedilinkEnglisharrow-up4·edit-214 天前the (ng) is silent when used in compound punctuation in ba(ng)
minus-square🌞 Alexander Daychilde 🌞@lemmy.worldlinkfedilinkEnglisharrow-up5·14 天前okay, but now THAT sounds racist for whole OTHER reasons… ;-)
minus-squareMinnesotaGoddam@lemmy.worldlinkfedilinkEnglisharrow-up3·14 天前it probably is, that professor who taught me it was belgian
minus-squareExec@pawb.sociallinkfedilinkarrow-up22·15 天前!!:n where n is the nth word after the command in your last line cp file1 file2 nano !!:2 Here nano opens file2.
minus-squareKristell@herbicide.fallcounty.omg.lollinkfedilinkarrow-up15·15 天前… How have I used Linux for two decades and not run into this once. Amazing stuff
minus-squareGreyEyedGhost@piefed.calinkfedilinkEnglisharrow-up9·14 天前I’ve never come across this before, and I am completely unsurprised it exists.
minus-squareOpenopenopenopen@lemmy.worldlinkfedilinkarrow-up8·edit-214 天前I think, if your using bash alt + . Does the same thing as typing !$ ls /super/long/path/to/dir cd alt + . I believe if you hit it again, it cycles through all previous last words https://ostechnix.com/list-useful-bash-keyboard-shortcuts/
minus-squareiturnedintoanewt@lemmy.worldlinkfedilinkarrow-up7·14 天前And there goes my daily new knowledge snippet! Thanks!
minus-squaregothic_lemons@lemmy.worldlinkfedilinkarrow-up4·14 天前Holy fucking shit. I’ve dabbled in Linux for so long to not know. Thank you!
minus-squareRaja@lemmy.worldlinkfedilinkarrow-up3·15 天前In some shells (e.g. fish), “running” a directory changes to it so you can save keystrokes and just delete the "ls ".
minus-squarequarrel4you@piefed.sociallinkfedilinkEnglisharrow-up3·15 天前I like the way you think! Too bad a I replied to a seaming empty post some 26 min after you. I always disliked this about Reddit. Seeing someone rewording the top reply for karma.
You mean something like this?
ls /your/long/path/namecd !$To add,
!$ gets replaced with the last word from the previous command line
!! Repeats the most recent command
!-N Repeats the Nth previous command
!string Repeats the most recent command that began with ‘string’
I just learned more about Linux than I did from my whole IT degree.
You learned more about shells than you knew. This stuff works on BSD and some UNIX systems too, you know
Most POSIX-compliant systems?
I learned Ubuntu in uni decades ago, and I didn’t know those commands exist.
!!is the goat when you needed to run the last command usingsudoHot damn, and here’s me thinking thefuck was the way to do this.
💯
If
!$isn’t pronounced “ba-ching!” I’m quitting LinuxBetter than “bang-ching” which sounds racist to me. lol
Great, now omarchy is going to adopt it
the (ng) is silent when used in compound punctuation in ba(ng)
okay, but now THAT sounds racist for whole OTHER reasons… ;-)
it probably is, that professor who taught me it was belgian
!!:nwhere n is the nth word after the command in your last linecp file1 file2 nano !!:2Here nano opens file2.
Love it
… How have I used Linux for two decades and not run into this once. Amazing stuff
I’ve never come across this before, and I am completely unsurprised it exists.
I’m loving this
Huh - TIL about !-N
Thanks 🙏
I think, if your using bash
alt + .
Does the same thing as typing
!$
ls /super/long/path/to/dir
cd alt + .
I believe if you hit it again, it cycles through all previous last words
https://ostechnix.com/list-useful-bash-keyboard-shortcuts/
And there goes my daily new knowledge snippet! Thanks!
Holy fucking shit. I’ve dabbled in Linux for so long to not know. Thank you!
In some shells (e.g. fish), “running” a directory changes to it so you can save keystrokes and just delete the "ls ".
I like the way you think! Too bad a I replied to a seaming empty post some 26 min after you. I always disliked this about Reddit. Seeing someone rewording the top reply for karma.