#learnshell
Explore tagged Tumblr posts
wzulfikar · 10 years ago
Text
Shall I Shell?
Doing repetitive work is unpleasant. Why shall I execute some code to setup my workspace? I shall shell it
What I mean by shell it is to make shell script for automating my task.
As stated in wikipedia, a shell script is a computer program designed to be run by the Unix shell, a command line interpreter1. For example, to start my laravel application I need to:
Go to Desktop/laravel
Execute php artisan serve from terminal
What I want to achieve:
Execute one file to start laravel server
Since I want to start my laravel project by executing one file from my desktop, I will create a file named init.sh in my desktop. *.sh is file extension for shell script.
My desktop now contains 2 things:
init.sh
laravel
Inside init.sh, I put some codes to start laravel server:
#Get current directory of this file #and `cd` to current directory CURRENT_DIR=$(dirname $0) cd $CURRENT_DIR #Now since my current directory is at same level #as my laravel directory, to start laravel server I can do: php laravel/artisan serve
Of course, I need to make that init.sh file executable. I'll just type this code in terminal:
chmod +x /Users/Mac/Desktop/init.sh
All settled :D. Now, to start laravel server I just need to click my init.sh file and open with terminal.
Anyway, how to install laravel? -- Just check on my related posts below :)
Related posts:
OSX and Laravel in 3 Steps
https://en.wikipedia.org/wiki/Shell_script ↩︎
0 notes