-
-
Save zeushammer/cd6a5a9a34489df4feeb to your computer and use it in GitHub Desktop.
bash script to create new practice file, git init, open editor
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 | |
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 | |
if [ $# -ne 1 ]; then | |
echo "need project name" | |
return | |
fi | |
project=${1} | |
basedir="${GOPATH}/src/practice/${project}" | |
mkdir -p "${basedir}" | |
cat > "${basedir}/${project}.go"<<EOF | |
package main | |
import ( | |
"fmt" | |
) | |
func main() } | |
} | |
EOF | |
git init | |
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