abbadon420@sh.itjust.works to Ask Lemmy@lemmy.world · 18 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-square19linkfedilinkarrow-up165arrow-down10file-text
arrow-up165arrow-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 · 18 hours agomessage-square19linkfedilinkfile-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-up48·18 hours agoYou mean something like this? ls /your/long/path/name cd !$
minus-squareiturnedintoanewt@lemmy.worldlinkfedilinkarrow-up1·1 hour agoAnd there goes my daily new knowledge snippet! Thanks!
minus-squaregothic_lemons@lemmy.worldlinkfedilinkarrow-up1·4 hours agoHoly fucking shit. I’ve dabbled in Linux for so long to not know. Thank you!
minus-squareOpenopenopenopen@lemmy.worldlinkfedilinkarrow-up5·11 hours 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-squarevalar@lemmy.calinkfedilinkarrow-up47·17 hours 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-squarem-p{3}@lemmy.calinkfedilinkarrow-up18·17 hours ago!! is the goat when you needed to run the last command using sudo
minus-squareccunning@lemmy.worldlinkfedilinkarrow-up2arrow-down1·17 hours agoHuh - TIL about !-N Thanks 🙏
minus-squareRaja@lemmy.worldlinkfedilinkarrow-up2·17 hours agoIn some shells (e.g. fish), “running” a directory changes to it so you can save keystrokes and just delete the "ls ".
You mean something like this?
ls /your/long/path/namecd !$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!
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/
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’
!!is the goat when you needed to run the last command usingsudo💯
I’m loving this
Huh - TIL about !-N
Thanks 🙏
In some shells (e.g. fish), “running” a directory changes to it so you can save keystrokes and just delete the "ls ".