Friday, May 2, 2014

Adding components to finder toolbar

In previous versions of Mac, you can just drag & drop apps to the finder window, but with Mavericks, you also need to hold the cmd button while drag & drop.

Unix Startup Scripts

There is always a confusion on which dot file to use to initialise environment variables under unix (i.e) .bash_profile , /etc/profile , .bashrc, .bash_login et.al?

There is two different types of shells called login shell & interactive shell and each has it own sequence of dot files to look for while starting. How do you differentiate them ? When trying to remotely login through ssh or any shell which asks to login is considered as login shell.



In the case of a login shell, the /etc/profile file is sourced first. Then it looks for the files in below sequence
.bash_profile -> ~/.bash_login -> .profile and whichever is found first & readable is executed.

In the case of a interactive shell, then it looks for ~/.bashrc and executes it if present.

On my setup  what ideally I do is to keep my environment variables in ~./profile file as the subshell (or) subprocess would inherit that. All the alias definitions would go into the ~/.bashrc file.

A good reference is available here


How to open more than one instance of the app in mac

Normally you can only open one instance of the application in mac from the applications menu.. To open multiple instances here is a way to do it - either open a terminal & type open -n <The .app file path' or create a apple script which will do it for you. Make sure you save it as .app to launch it as an application.

Below is an example for a sample script i have created to launch multiple instances of soap ui.


simple hack to open unauthorized apps in mac

By default the security & privacy setting in mac would allow you open applications downloaded from appstore & identified developers. The apps that you download from web, normally they are not allowed to be opened and a simple hack to do is to press command and double click on the app. This will open a window with a warning having a open button. The other option is to change the security & privacy setting to open applications downloaded from anywhere and that could be a bit risky.




bash vs sh

There is always a confusion as to why we define the following while writing a shell script in unix based system:
#! /bin/sh (or) #! /bin/bash
#! is known as shebang which lets the rest of the line to be considered as a interpreter directive by the program loader. Thus the program loader knows which interpreter needs to be used to execute the shell script.
sh - Bourne Shell used to be the default shell of the old unix systems.
bash - Bourne-again shell is the outcome of the GNU project and it supersedes sh. In Mac and most of the linux distributions bash is shipped as the default interpreter. In fact sh is considered as a system shell and hence in most distributions is mostly a symbolic link to bash.