diff --git a/IPython/core/profileapp.py b/IPython/core/profileapp.py index 4520c4acbe2..f83fd1396fb 100644 --- a/IPython/core/profileapp.py +++ b/IPython/core/profileapp.py @@ -85,6 +85,8 @@ _main_examples = """ ipython profile create -h # show the help string for the create subcommand ipython profile list -h # show the help string for the list subcommand + +ipython locate profile foo # print the path to the directory for profile 'foo' """ #----------------------------------------------------------------------------- @@ -115,6 +117,18 @@ def list_bundled_profiles(): return profiles +class ProfileLocate(BaseIPythonApplication): + description = """print the path an IPython profile dir""" + + def parse_command_line(self, argv=None): + super(ProfileLocate, self).parse_command_line(argv) + if self.extra_args: + self.profile = self.extra_args[0] + + def start(self): + print self.profile_dir.location + + class ProfileList(Application): name = u'ipython-profile' description = list_help @@ -277,8 +291,8 @@ class ProfileApp(Application): examples = _main_examples subcommands = Dict(dict( - create = (ProfileCreate, "Create a new profile dir with default config files"), - list = (ProfileList, "List existing profiles") + create = (ProfileCreate, ProfileCreate.description.splitlines()[0]), + list = (ProfileList, ProfileList.description.splitlines()[0]), )) def start(self): diff --git a/IPython/frontend/terminal/ipapp.py b/IPython/frontend/terminal/ipapp.py index 310944d041b..e33e30972d6 100755 --- a/IPython/frontend/terminal/ipapp.py +++ b/IPython/frontend/terminal/ipapp.py @@ -78,6 +78,9 @@ ipython profile create foo # create profile foo w/ default config files ipython help profile # show the help for the profile subcmd + +ipython locate # print the path to the IPython directory +ipython locate profile foo # print the path to the directory for profile `foo` """ #----------------------------------------------------------------------------- @@ -180,6 +183,21 @@ def make_report(self,traceback): # Main classes and functions #----------------------------------------------------------------------------- + +class LocateIPythonApp(BaseIPythonApplication): + description = """print the path to the IPython dir""" + subcommands = Dict(dict( + profile=('IPython.core.profileapp.ProfileLocate', + "print the path to an IPython profile directory", + ), + )) + def start(self): + if self.subapp is not None: + return self.subapp.start() + else: + print self.ipython_dir + + class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp): name = u'ipython' description = usage.cl_usage @@ -219,6 +237,9 @@ def _classes_default(self): console=('IPython.frontend.terminal.console.app.ZMQTerminalIPythonApp', """Launch the IPython terminal-based Console.""" ), + locate=('IPython.frontend.terminal.ipapp.LocateIPythonApp', + LocateIPythonApp.description + ), )) # *do* autocreate requested profile, but don't create the config file. diff --git a/docs/source/config/overview.txt b/docs/source/config/overview.txt index a0f6a0bd8b6..759fe4b909a 100644 --- a/docs/source/config/overview.txt +++ b/docs/source/config/overview.txt @@ -281,7 +281,7 @@ configuration, and by default, all profiles will be stored in the so called "IPython directory". The location of this directory is determined by the following algorithm: -* If the ``ipython_dir`` command line flag is given, its value is used. +* If the ``ipython-dir`` command line flag is given, its value is used. * If not, the value returned by :func:`IPython.utils.path.get_ipython_dir` is used. This function will first look at the :envvar:`IPYTHONDIR` @@ -324,6 +324,25 @@ under :file:`profile_default`. If you want the default config files for the :mod:`IPython.parallel` applications, add ``--parallel`` to the end of the command-line args. + +Locating these files +-------------------- + +From the command-line, you can quickly locate the IPYTHONDIR or a specific +profile with: + +.. sourcecode:: bash + + $> ipython locate + /home/you/.ipython + + $> ipython locate profile foo + /home/you/.ipython/profile_foo + +These map to the utility functions: :func:`IPython.utils.path.get_ipython_dir` +and :func:`IPython.utils.path.locate_profile` respectively. + + .. _Profiles: Profiles