Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: command to find location of rc.elv file #1385

Closed
ajeetdsouza opened this issue Aug 22, 2021 · 6 comments
Closed

Feature request: command to find location of rc.elv file #1385

ajeetdsouza opened this issue Aug 22, 2021 · 6 comments

Comments

@ajeetdsouza
Copy link

Now that #383 has been fixed, the location of rc.elv is less obvious. It would be nice if there was an Elvish command to determine the location of rc.elv. Other shells that vary the location of their config files based on OS or environment variables already provide a way to do this:

  • PowerShell: echo $profile
  • Nushell: config path
@krader1961
Copy link
Contributor

Without commenting on whether or not this should be implemented I'll note that you can capture this information today when rc.elv is executed using the src builtin. For example, by adding something like this to your rc.elv: var rc-elv-path = (src)[name].

@zzamboni
Copy link
Contributor

Expanding on this feature request, I think it would be nice to have variables or functions which contain all the different directories of the XDG spec. If the user is still using the ~/.elvish/ directory, then they could all point to the same directory.

This would significantly simplify the work of module authors when there is a need to store data somewhere.

@krader1961
Copy link
Contributor

My recommendation is to implement this as variables in the platform module; e.g., platform:xdg-config-home (corresponding to the XDG_CONFIG_HOME env var in the XDG Base Directory spec). Whether or not the xdg- prefix is warranted is debatable but I think it should be present to make the correspondence to the XDG spec env vars crystal clear. The value of each variable would match whatever Elvish decided to use at runtime even if that means using the legacy ~/.elvish path.

Note that the proposed platform:xdg-config-home would not include the final /rc.elv path component -- only the directory containing the rc.elv that was loaded.

@krader1961
Copy link
Contributor

I opened issue #1420 when I was surprised that the ~/.config/elvish/rc.elv I synced from my macOS to Windows 10 system was not read on the latter system. I might have found the problem, without resorting to add a fmt.Printf() call to the source, if this issue were resolved. However, in light of the fact that Elvish on MS Windows doesn't (currently) recognize XDG paths is a strong suggestion that the names of the variables to expose this information should be agnostic with regards to the XDG spec. Rather, the names should reflect the use of each value by Elvish.

@krader1961
Copy link
Contributor

Note that building elvish from HEAD as I type this will result in this warning if you use github.com/href/elvish-gitstatus:

Warning: ~/.elvish will be ignored from Elvish 0.20.0.

That is because that module has a hardcoded path: var appdir = ~/.elvish/package-data/gitstatus. As I discuss in issue #832 third-party modules really need a way to ask Elvish which dir it is using without having to implement the logic documented in https://elv.sh/ref/command.html.

@krader1961
Copy link
Contributor

FWIW, I've been working on implementing this feature. I've decided that the var for this issue should be named platform:config-home. Also, a companion platform:state-home (corresponding to where the Elvish database file is located) also be introduced for use by modules like github.com/href/elvish-gitstatus for its data that normally should be private to a particular machine. I intend to leave exposing module search paths for a future change in order to keep the initial change as small as possible.

krader1961 added a commit to krader1961/elvish that referenced this issue Jun 22, 2022
There are several paths used by Elvish internally that should also be visible
to Elvish scripts. This change exposes two of those paths via the `platform`
module. Thus making it easier for Elvish scripts to determine where various
files live and, more importantly, should be written. The latter is especially
important for transient state files that should be placed in the same,
or a subdirectory of, the directory used for the Elvish database file.

Resolves elves#1385
krader1961 added a commit to krader1961/elvish that referenced this issue Jun 22, 2022
There are several paths used by Elvish internally that should also be visible
to Elvish scripts. This change exposes two of those paths via the `platform`
module. Thus making it easier for Elvish scripts to determine where various
files live and, more importantly, should be written. The latter is especially
important for transient state files that should be placed in the same,
or a subdirectory of, the directory used for the Elvish database file.

Resolves elves#1385
krader1961 added a commit to krader1961/elvish that referenced this issue Jun 22, 2022
There are several paths used by Elvish internally that should also be visible
to Elvish scripts. This change exposes two of those paths via the `platform`
module. Thus making it easier for Elvish scripts to determine where various
files live and, more importantly, should be written. The latter is especially
important for transient state files that should be placed in the same,
or a subdirectory of, the directory used for the Elvish database file.

Resolves elves#1385
krader1961 added a commit to krader1961/elvish that referenced this issue Jun 24, 2022
There are several paths used by Elvish internally that should also be visible
to Elvish scripts. This change exposes three of those paths via the `platform`
module. Thus making it easier for Elvish scripts to determine where various
files live and, more importantly, should be written. The latter is especially
important for transient state files that should be placed in the same,
or a subdirectory of, the directory used for the Elvish database file.

Resolves elves#1385
@xiaq xiaq closed this as completed in 9794eec Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants