Last active
December 14, 2015 19:33
-
-
Save gugat/39e996f20026c8089867 to your computer and use it in GitHub Desktop.
Utility to go to any directory (previously configured in the script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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