Mac – Bash – Set and Change to Current Folder

email me

#!/bin/bash
## set current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

## change directory
cd ${DIR}

${} quoting for variables.

$() quoting for commands.

dirname is path of argument.

cd changes current directory.

pwd returns current path.

&& run next command.