abbadon420@sh.itjust.works to Ask Lemmy@lemmy.world · 16 hours 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-square52fedilinkarrow-up191arrow-down10file-text
arrow-up191arrow-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 · 16 hours agomessage-square52fedilinkfile-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-squarenotabot@piefed.sociallinkfedilinkEnglisharrow-up16·15 hours agoType cd then press Alt+. and it’ll copy the last argument of the previous command, make sure it’s what you want, and press Enter.
minus-squaresin_free_for_00_days@sopuli.xyzlinkfedilinkEnglisharrow-up3·10 hours agoNice, I don’t remember having seen that before. I’m sure I’ll just keep using !$, because muscle memory, but I like seeing new approaches.
minus-squarenotabot@piefed.sociallinkfedilinkEnglisharrow-up2·6 hours agoThe shell, and lots of other things that take per-line input, use readline to do it. The readline man page is… extensive… to say the least. There are many more useful shortcuts in there, but I doubt anyone uses more than a fraction of them.
Type
cdthen pressAlt+.and it’ll copy the last argument of the previous command, make sure it’s what you want, and pressEnter.Nice, I don’t remember having seen that before. I’m sure I’ll just keep using !$, because muscle memory, but I like seeing new approaches.
The shell, and lots of other things that take per-line input, use
readlineto do it. Thereadlineman page is… extensive… to say the least. There are many more useful shortcuts in there, but I doubt anyone uses more than a fraction of them.