It’s all started when I was assigned to develop a Rails web app with Haris as a team. He worked on the Rails side, while I’m on the HTML / CSS. It was my first time using Rails, and I barely have any experience on web development. Haris told me that there are several commands that should be executed to enable developing the web locally :
rvm gemset use iceberg,
bundle exec rails s,and
bundle exec foreman startfor running Redis server (on other terminal instance)
At that time, I typed all of those commands on my terminal each time I start working on the app, until I’ve made an embarrassing mistake – twice.
There was an “upload image” feature that we worked on, and I was trying to add the CSS when all image already uploaded. I ran the Rails app on my local machine, and tried to upload the an image to check whether my CSS really loads or not. The image upload process doesn’t finish after a good five minutes, which is strange – since it usually takes around 10 seconds max (local machine, duh). I cancelled the upload and tried to re-upload, only to see the same page stuck on uploading image. Baffled, I asked Haris for help.
Me (E) : Haris, can you check this for a sec? My image upload process never ends.
Haris (H) : Okay. *opens up Sidekiq on the other tab*
E : Something’s wrong?
H : These Carrierwave background processes queued instead of failed… Have you run the Redis server?
E : Redis what?
H : Redis server.
bundle exec foreman start.
E : *slaps head*
After running on the same problem twice (yes, shame on me), I considered to automate these error-prone task. That’s when I remembered the cursed-yet-worked hammer, Bash. I made a “Scripts” folder on my root directory, and wrote four bash scripts that will change to the project directory and run the commands :
Each time I starts develop the app, I split my iTerm window to four panes and ran each script using
source command, which will enable changing directories. It spawned this four beauties :
And with this, the forgot-redis-server issue is no more! 🙂
Today, I’m finding myself using this method on each project I worked on – including the mobile ones. Let’s say I got an iOS app with Cocoapods, I use this template script :
This will conveniently open up the project’s workspace and installing pods at the same time – which is less writing
cd commands on my terminal, and a good thing for me 🙂
Lastly, I also use these scripts to open my work apps on the start of the day. I use these apps on my daily routine :
And I opened all of them using scripts. First, I add aliases for each app on my .zshrc to enable opening the app via iTerm :
Then, I wrap them on these scripts :
I separated the chat apps from the others to open them without the rest – usually when I feel like reading shared articles on Slack during the weekend. This way, I can open up the terminal, run
source workapps.sh and fill my glass of water while waiting the apps to load, right when I arrived at the office.
I know that I used fairly simple bash scripts to achieve this, and there might be (a lot of) developers who use more sophisticated scripts to set up their workspace. But if you never use scripts to automate your workspace, you can try the samples that I gave above 🙂
Thank you for reading! 🙂
UPDATE : A senior on my workplace, Pria, suggested me to use GitHub gists instead of quoted codes. It does look better – Thanks Mas Pria! 🙂