Creating a bash routine

0

Everytime I log in into my work machine, I have to open a terminal and type the same routine:

$ cd /Documents/some_folder/some_another_folder
$ vagrant up
$ vagrant ssh

I'd like these commands to execute one after another, by just typing something like $ initvm.

I thought about creating an alias for the $ cd call inside .bashrc but then I thought about doing the 3 of them in 1 function or similar. Thing is I am not sure where to define this:

  1. Define the routine in a initvm.sh file and alias that file inside .bashrc
  2. Define the routine inside .bashrc

Can I get some directions on this please?

Christopher Francisco

Posted 2015-05-16T14:38:47.760

Reputation: 238

Use a function in your .bashrc. – Cyrus – 2015-05-16T14:59:41.490

Answers

2

I think you can simply create one new alias in your .bashrc file, e.g.:

alias go='cd /Documents/some_folder/some_another_folder && vagrant up && vagrant ssh'

See this answer to similar question https://stackoverflow.com/a/756772

SnY

Posted 2015-05-16T14:38:47.760

Reputation: 34

1

Just add those commands to your .bashrc file one line for each command if you want them executed everytime you open the bash .

Otherwise use the answer from SnY and mind the single quotes to have to enter the alias to execute the commands.

Dean Spicer

Posted 2015-05-16T14:38:47.760

Reputation: 611