You need to write a batch file in Windows (in case of Linux they are called shell script). It is very easy to write once you know what commands to use (In your case you already know the commands). In a batch file you need to write down the commands in the order in which you want them to execute. To create a batch file, open a Notepad and write down those commands in order and save the file with .bat extension. Next you just need to double click that .bat file and it will do all your task. Just giving you an example of how your batch file should look like.
cd /your/working/directory/path
jekyll s
start chrome "http://localhost:4000/"
Basic input/output operation in batch file
Taking input from the user: [Command used set
]
Syntax: set /p variable_name=[Prompt String]
Example: set /p loc="Enter the directory path : "
This will prompt for an input from the user and will assign it to the variable loc
.
Displaying message/output on the screen: [Command used echo
]
Syntax: echo <your_message_here>
Example: echo Hello World
Will display "Hello World" on the screen. To print the content of a variable using echo
use echo %variable_name%
. Say you want to display the content of the variable my_name
. Then the command will be echo Hello %my_name%
.
Making your script more interactive using these commands.
echo off
::The above command hides the commands that are executed and displays only the output of the commands
set /p loc="Enter your project directory location : "
cd /d %loc%
echo Directory changed...
jekyll s
echo Launching browser...
start chrome "http://localhost:4000/"
echo End of script...
pause
::
is used for commenting. To know more about a particular command use /?
after the command name to display the manual for that command which contains what the command does and all the options that are available for it. For example to know more about the cd
command enter cd /?
in the prompt.
Here is a nice tutorial for beginners.