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