abbadon420@sh.itjust.works to Ask Lemmy@lemmy.world · 2 days agoLinux 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-square62fedilinkarrow-up1123arrow-down11file-text
arrow-up1122arrow-down1message-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 · 2 days agomessage-square62fedilinkfile-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-up115·2 days agoYou mean something like this? ls /your/long/path/name cd !$
minus-squareiturnedintoanewt@lemmy.worldlinkfedilinkarrow-up7·22 hours agoAnd there goes my daily new knowledge snippet! Thanks!
minus-squarevalar@lemmy.calinkfedilinkarrow-up106·edit-22 days agoTo 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-square4am@lemmy.ziplinkfedilinkarrow-up25·1 day agoIf !$ isn’t pronounced “ba-ching!” I’m quitting Linux
minus-square🌞 Alexander Daychilde 🌞@lemmy.worldlinkfedilinkEnglisharrow-up10·1 day agoBetter than “bang-ching” which sounds racist to me. lol
minus-squareMinnesotaGoddam@lemmy.worldlinkfedilinkEnglisharrow-up3·edit-216 hours agothe (ng) is silent when used in compound punctuation in ba(ng)
minus-square🌞 Alexander Daychilde 🌞@lemmy.worldlinkfedilinkEnglisharrow-up4·16 hours agookay, but now THAT sounds racist for whole OTHER reasons… ;-)
minus-squareMinnesotaGoddam@lemmy.worldlinkfedilinkEnglisharrow-up3·15 hours agoit probably is, that professor who taught me it was belgian
minus-squareSkaveRat@discuss.tchncs.delinkfedilinkarrow-up6·22 hours agoGreat, now omarchy is going to adopt it
minus-squarevillage604@adultswim.fanlinkfedilinkEnglisharrow-up47·2 days agoI just learned more about Linux than I did from my whole IT degree.
minus-squareBlue Label@lemmy.worldlinkfedilinkEnglisharrow-up1·9 hours agoI learned Ubuntu in uni decades ago, and I didn’t know those commands exist.
minus-square4am@lemmy.ziplinkfedilinkarrow-up16·edit-21 day agoYou learned more about shells than you knew. This stuff works on BSD and some UNIX systems too, you know
minus-squareGreyEyedGhost@piefed.calinkfedilinkEnglisharrow-up3·1 day agoMost POSIX-compliant systems?
minus-squarem-p{3}@lemmy.calinkfedilinkarrow-up34·2 days ago!! is the goat when you needed to run the last command using sudo
minus-squareHal@piefed.nzlinkfedilinkEnglisharrow-up9·1 day agoHot damn, and here’s me thinking thefuck was the way to do this.
minus-squareExec@pawb.sociallinkfedilinkarrow-up21·1 day ago!!: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-up14·1 day ago… How have I used Linux for two decades and not run into this once. Amazing stuff
minus-squareGreyEyedGhost@piefed.calinkfedilinkEnglisharrow-up8·1 day agoI’ve never come across this before, and I am completely unsurprised it exists.
minus-squareccunning@lemmy.worldlinkfedilinkarrow-up3arrow-down1·2 days agoHuh - TIL about !-N Thanks 🙏
minus-squaregothic_lemons@lemmy.worldlinkfedilinkarrow-up3·1 day agoHoly fucking shit. I’ve dabbled in Linux for so long to not know. Thank you!
minus-squareOpenopenopenopen@lemmy.worldlinkfedilinkarrow-up7·edit-21 day agoI 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-squareRaja@lemmy.worldlinkfedilinkarrow-up2·2 days agoIn 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-up2·2 days agoI 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 !$And there goes my daily new knowledge snippet! Thanks!
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’
If
!$isn’t pronounced “ba-ching!” I’m quitting LinuxBetter than “bang-ching” which sounds racist to me. lol
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
Great, now omarchy is going to adopt it
I just learned more about Linux than I did from my whole IT degree.
I learned Ubuntu in uni decades ago, and I didn’t know those commands exist.
You learned more about shells than you knew. This stuff works on BSD and some UNIX systems too, you know
Most POSIX-compliant systems?
!!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.
💯
!!: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 🙏
Holy fucking shit. I’ve dabbled in Linux for so long to not know. Thank you!
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/
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.