5 ms·
Hey that's cool stuff. For a total ignorant like me, where should I go to learn the basics of automating some tasks like I'd like to type $ ipaddress and get th
by Entangled 10y ago
Hey that's cool stuff. For a total ignorant like me, where should I go to learn the basics of automating some tasks like I'd like to type $ ipaddress and get the local ip address instead of $ ipconfig getifaddr en0. Is that bash? How is that called? How do I make "programs" to automate tasks and run them from terminal with a single customized word like dbstart dbstop?
Thanks for the pointers.
- molloy 10y agoThe first way that comes to mind is to use alias, e.g. `alias ipaddress="ipconfig getifaddr en0"`. Then running `ipaddress` would do what you want. To avoid having to run this again every time you log in, you can add the same line to your `~/.bash_profile`, which configures your shell when you log in before the initial command prompt. You can then type `source ~/.bash_profile` to reload your configuration without having to log out then back in.
- sethrin 10y agoor just box$ . ~/.bash_profile But I prefer zsh/prezto. I spend far too much time on the command line, so I want it to look pretty and tab-complete all the things.
- Entangled 10y agoOk, so I write a bash script then create an alias for it like alias hello="bash hello.sh" Something like that? I found some nice bash tutorials that'll keep me busy for the weekend. Thanks. Edit: Ok, apparently alias hello is not needed since hello.sh can be run directly with just the name, I was having permission problems and couldn't make it run, but now with just $ hello I can see the output. I'm loving it!