I have a script called foo.R that includes another script other.R, which is in the same directory:
foo.R
other.R
#!/usr/bin/env Rscript message(\
I have wrapped up and extended the answers to this question into a new function thisfile() in rprojroot. Also works for knitting with knitr.
thisfile()
knitr