Skip to content

Instantly share code, notes, and snippets.

@zeushammer
Forked from billhathaway/gist:a2efe9e179e654f77ed5
Last active August 29, 2015 14:24
Show Gist options
  • Save zeushammer/cd6a5a9a34489df4feeb to your computer and use it in GitHub Desktop.
Save zeushammer/cd6a5a9a34489df4feeb to your computer and use it in GitHub Desktop.
bash script to create new practice file, git init, open editor
#!/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