Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Mastering Bash and Terminal (2017) (blockloop.io)
70 points by gautamsomani on Dec 10, 2021 | hide | past | favorite | 13 comments


I'm glad to see this has aged well and still provides value. I plan to write V2 sometime in the near future.


Discussed at the time:

Mastering Bash and Terminal - https://news.ycombinator.com/item?id=13400350 - Jan 2017 (180 comments)


About two years ago, a change in work caused me to become a heavy git user. One of the most important changes I made to my bash setup was to change my prompt to multi line, detect whether I was in a git repo, include the branch in the prompt, and also include a summary of git status.

Very handy! (The check also makes sure I am in the repo part of the repo, and not, say, in its .git folder or other non-working folders.)


> One of the most important changes I made to my bash setup was to change my prompt to multi line, detect whether I was in a git repo, include the branch in the prompt, and also include a summary of git status.

Check out starship[1] if you haven't already. It's a prompt that does just this and more, and works across shells like Bash, fish, zsh, etc.

[1] https://github.com/starship/starship


Thanks! I will definitely check that out!


If you want all this and some more without setting it up yourself, oh-my-zsh spaceship prompt theme is great...

I don't feel at home at a terminal without it by now, so one of my first installs after brew ;-)

https://github.com/spaceship-prompt/spaceship-prompt


My favorite for this purpose is pure prompt: https://github.com/sindresorhus/pure

I wasn’t sure about multi line at first, but really digging it now.


I know zsh has all the new fancy stuff but keeping the bash shell as default for macOS would have made my life just a little bit easier.


Thankfully you can change it. First thing I do when setting up a new mac: install Homebrew and change my shell to the bash that comes in Homebrew.


Surprised not to see a mention of “!!” here, I use that a decent amount


That's one I forgot to mention but I do use it a lot. I don't know if you know this but you can also do a substitution on the previous command. I often do something like `ssh root@proxmox01` and then `!!:s/1/2` which runs it again, but substitutes 1 for 2 and executes `ssh root@proxmox02`.

edit: I realize that example fails the speed test vs `ctrl+p, backspace, 2, enter`, but hopefully you can see the value.


could that just be shortened down to ^1^2?


I use "sudo !!" all the time, it's really useful.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: