Skip to content

Instantly share code, notes, and snippets.

@Arxcis
Last active September 16, 2018 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arxcis/7780b55ea94b6f6ca113da0b9db78a90 to your computer and use it in GitHub Desktop.
Save Arxcis/7780b55ea94b6f6ca113da0b9db78a90 to your computer and use it in GitHub Desktop.
refactor goto.sh
!/bin/bash
PROJECT=`cat ${HOME}/.goto/active-project`
GOTOPATH="${HOME}/.goto/projects/${PROJECT}.json"
GOTO="/usr/local/opt/goto/the_real_goto.py"
# Special case no 1
if [ "$1" = "cd" ]; then
# hack to cd in this shell to the ouput of goto show <magicword>
path=`goto show "$2"`
cd "$path"
exit
fi
# Special case no 2
if [ "$#" -eq 1 ]; then
path=$(python /usr/local/opt/goto/the_real_goto.py "$GOTOPATH" show "$2")
if [ -d "$path" ]; then
cd "$path"
exit
fi
fi
# General case
python /usr/local/opt/goto/the_real_goto.py "$GOTOPATH" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment