Skip to content

Instantly share code, notes, and snippets.

@jsta
Forked from noamross/mkrproj.sh
Created January 3, 2018 00:23
Show Gist options
  • Save jsta/1b97796322cf92214444006987fa9114 to your computer and use it in GitHub Desktop.
Save jsta/1b97796322cf92214444006987fa9114 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
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Yes
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8
RnwWeave: knitr
LaTeX: XeLaTeX
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
QuitChildProcessesOnExit: Yes
"
gtemplate=".Rproj.user
.Rhistory
.RData
.Ruserdata
"
wd=$(basename "`pwd`")
if [ -z $1 ]; then
projectname=$wd
else
projectname=$1
fi
echo "${template}" > "${projectname}.Rproj"
echo "${gtemplate}" > .gitignore
# 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