Re:Ask HN: What are your favorite one-liner shell commands y...
by scrapheap on Thursday July 17, 2025 @03:00AM
(#44590524)
`cd -` is great for when you just want to nip out of your current directory for a second and then come straight back - especially as I'm pretty sure that most of us never think about pushd/popd until after we've moved to the other directory with cd :)
Re:Ask HN: What are your favorite one-liner shell commands y...
by 000ooo000 on Thursday July 17, 2025 @03:21AM
(#44590647)
Semi-related: if I want to do a little side quest, maybe pop over to another repo or git worktree for a quick look, I'll drop into a subshell just by running bash before cd-ing. Then I just exit that shell (alias q=exit) when I want to return back to the original dir and context.
Re:Ask HN: What are your favorite one-liner shell commands y...
by scrapheap on Thursday July 17, 2025 @03:36AM
(#44590715)
You know that you can just press <CTRL+D> at the bash prompt to quit it as well? (In fact <CTRL+D> will quit out of most command line programs as it's the End Of Transmission character)
Re:Ask HN: What are your favorite one-liner shell commands y...
by vinhnx on Thursday July 17, 2025 @01:15AM
(#44589912)
I also same here. Has since I discovered Ctrl+R, and equipped it with fzf (https://github.com/junegunn/fzf), every terminal command is in my hand, I can fuzzy search and not need to remember the exact command. This really saved me a lot of times.
Re:Ask HN: What are your favorite one-liner shell commands y...
by rajkumarsekar on Friday July 18, 2025 @01:27AM
(#44601510)
No need to be fancy. These are super practical! ctrl+r is a lifesaver once it clicks, and cd - is such a small thing that makes moving around so much smoother.
More to the letter of the question, I use "cd -" frequently, "ps -e | grep some_process_i_would_like_the_pid_for", and while I don't use it frequently, I didn't know about "ssh-copy-id" for a long time, and would do it manually with a text editor in the past. Sorry if they are not sufficiently fancy - but for things to get used day to day for me, they will need to be short and sweet.