Skip to content

Instantly share code, notes, and snippets.

@bearloga
Last active January 3, 2018 14:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bearloga/86f427118543446e5aefb6955b8b0574 to your computer and use it in GitHub Desktop.
Save bearloga/86f427118543446e5aefb6955b8b0574 to your computer and use it in GitHub Desktop.
A bash shell script that can be used to turn the current directory into an RStudio project, opening the project in RStudio after creating it.
#!/bin/bash
# Usage: mkproj [projectname]
# projectname defaults to name of current directory
template="Version: 1.0\nRestoreWorkspace: Default\nSaveWorkspace: Default\nAlwaysSaveHistory: Default\n\nEnableCodeIndexing: Yes\nUseSpacesForTab: Yes\nNumSpacesForTab: 4\nEncoding: UTF-8\n\nRnwWeave: knitr\nLaTeX: pdfLaTeX"
wd=$(basename `pwd`)
if [ -z $1 ]; then
projectname=$wd
else
projectname=$1
fi
echo ${template} > "${projectname}.Rproj"
# Open the newly created project in RStudio:
open "${projectname}.Rproj"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment