How I can create a batch alias for bash?
I need to do this:
cd /somefolder
bundle exec unicorn -p 3000
rackup faye.ru -s thin -E production
bundle and rackup - this is 2 servers
for example I want bind alias z=*all_of_this*
How I can create a batch alias for bash?
I need to do this:
cd /somefolder
bundle exec unicorn -p 3000
rackup faye.ru -s thin -E production
bundle and rackup - this is 2 servers
for example I want bind alias z=*all_of_this*
Bash functions are one method but I prefer to create separate scripts for things in my ~/bin/ directory:
mkdir ~/bin/
touch ~/bin/z
chmod +x ~/bin/z
gedit ~/bin/z
Then shove your script in there (with a header) so it looks like this:
#! /bin/bash
cd "$1"
bundle exec unicorn -p 3000
rackup faye.ru -s thin -E production
Then just call z <directory-path>.
It is a longer method than an alias or a bash function but I prefer it because it's a little more separable than munging things in with your other aliases. I won't blame you if you don't agree!
You don't want an alias; you want a bash function, which you can put in the same place as you put your aliases:
z() {
cd "$1" # This is the argument passed in
bundle exec unicorn -p 3000
rackup faye.ru -s thin -E production
}
Call it like this:
z /somefolder