Last active
August 29, 2015 14:24
-
-
Save billhathaway/a2efe9e179e654f77ed5 to your computer and use it in GitHub Desktop.
bash function to create and open a new file for programming challenges
This file contains 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
GOEDITOR="/Applications/Atom.app" | |
# practice does the following | |
# creates a new directory named after the project | |
# creates a file under that directory named $project.go with a small template | |
# NOTE: specifically not using main.go so I can distinguish the files in my editor tabs | |
# opens the file in my editor | |
# changes to the new project directory | |
practice() { | |
if [ $# -ne 1 ]; then | |
echo "need project name" | |
return | |
fi | |
project=${1} | |
basedir="${GOPATH}/src/bitbucket.org/billhathaway/practice/${project}" | |
mkdir -p "${basedir}" | |
cat > "${basedir}/${project}.go"<<EOF | |
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
} | |
EOF | |
open -a "${GOEDITOR}" "${basedir}/${project}.go" | |
cd "${basedir}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment