Skip to content

Instantly share code, notes, and snippets.

@gugat
Last active December 14, 2015 19:33
Show Gist options
  • Select an option

  • Save gugat/39e996f20026c8089867 to your computer and use it in GitHub Desktop.

Select an option

Save gugat/39e996f20026c8089867 to your computer and use it in GitHub Desktop.
Utility to go to any directory (previously configured in the script)
#!/bin/bash
#
# Author: Gustavo Salazar <guga.salazar.loor@gmail.com>
# Created: 2015-12-14
#
# Setup:
#
# * Place this script in /usr/local/bin/
#
# * Give execution permissions:
#
# chmod + x /usr/local/bin/goto
#
# * Edit the script. Add projects as variables. Example:
#
# awesome_project="/path/to/awesome/project"
# Usage:
#
# . goto <project_name>
#
# Example:
#
# . goto awesome_project
#
#
# Notes:
#
# The "dot command" is used to run the script in your current
# process and not in a subshell where the directory change won't be reflected.
#
# To avoid using the "dot command" create an alias in your .bash_profile
#
# alias goto=". /usr/local/bin/goto"
#
# Now you can use
#
# goto awesome
#
# PROJECT NAMES
awesome_project="/path/to/awesome/project"
my_project="/path/to/my/project"
if [ "$1" == "" ];then
echo ""
echo "usage: goto project_name"
echo ""
exit
fi
project=$1
directory=${!project}
cd $directory
echo "[$(pwd)]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment