get directory of a julia script

1,334 views
Skip to first unread message

Ryan Gardner

unread,
May 29, 2013, 12:57:50 PM5/29/13
to julia...@googlegroups.com
Is there a way I can get the directory of a julia script?

E.g., if I run /tmp/my_dir/foo.jl from anywhere, I want to get "/tmp/my_dir".  Something like an ARGS[0] that contains the name of the executable on the command line would work.

(I couldn't find anything like this in the documentation.)

Thanks.

Stefan Karpinski

unread,
May 29, 2013, 1:19:11 PM5/29/13
to julia...@googlegroups.com
It's not entirely official, hence not exported, but Base.source_path() will return the path of the current source file. You can do dirname(Base.source_path()) to get the directory of the current source file.
Reply all
Reply to author
Forward
0 new messages