-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add config.history.path
#14434
base: main
Are you sure you want to change the base?
Add config.history.path
#14434
Conversation
This was originally brought up in nushell#11962, but closed in favour of the more general nushell#10100. However this commit doesn't address the broader theme of using alternate XDG vars for the default history path. Here is the updated `sample_config.nu` documentation for the field: > # When this config doesn't exist or is set to null, then a default path is used > # based on the OS and ENV. > # > # You will likely want to match the file extension to the `file_format` setting, > # therefore ".txt" or ".sqlite". > # > # Nushell will create the file if it doesn't exist. However it won't create the > # directory path, and will error if it doesn't exist. > $env.config.history.path = null
Another thing I've just noticed is that when setting the path to a non-existent folder the custom error I've created doesn't cause startup to fail. Maybe it's just a logged error? |
As a user, I'm more in support of #10100. I feel that config and data files should be at fixed locations, not customized. Otherwise the data directory becomes too non-standard and a bit of a mess. If the user really wants to customize the path, they can create some symlink. I have done so myself for e.g. the Nushell config dir for version control. |
One of the reasons that I felt this was a reasonable idea is that it doesn't conflict with the defaults. The I can give an example of why a symlink isn't ideal in my case. I keep all my system config in a single directory and all my data for backup in another directory. Whilst symlinking certainly isn't a deal breaker for me, using real files does just make it easier and more obvious what my config is doing when I can put things exactly where I want them without any indirection. |
(Copy pasting from #10110) @tombh I like your idea of having a way to set an alternative history path. My motivation for this feature is that within a particular dev project, you typically need to run a fixed set of commands frequently, and often times those commands are similar to those you run in normal shell session, so that when you reverse search in the history, those similar commands from your normal session just clutter the history list, making the ones you really want harder to locate. The For me, Since I use direnv to spawn a development shell (with custom config & env file checked into git repo) when I enter the directory of a particular project, I can cope with any way of making such customization (env var, CLI flag or config entry ). Though from the POV of being in line with nushell's current way of doing things, I feel like a |
That's also a good use case, I hadn't thought of that. I'd be happy to add it. I'm not quite clear on the downsides of adding it to the config. Does it affect backward compatibility? My only comment is that I think it would make it a bit harder to set the default shell in Linux with |
Sorry for the confusion, I don't object adding to config in any way. My comment is based on how nushell currently specifies the three files it depends on: On the other hand, nushell currently only supports the CLI flag approach for specifying plugin file. And if you are in need of a custom plugin file in conjunction with But that's just how nushell is today, and it certainly can/should be improved. Though the core devs might have other concerns that are beyond my sight. |
Ohh yes, that makes sense. And I agree. And I'd be happy to add a CLI flag in this PR. I'll just wait for some feedback from the core team before I make any more changes.
That's a shame. I guess that should be addressed in another issue and PR. BTW I read your comment in the other thread:
That's a really good point. I think that's the best example of why being able to explicitly set the history path is important. Nushell launches other programs, and so passes on its XDG settings. I guess a user could pass one |
@tombh Looking forward to see this PR landed! Thank you in advance! |
Testing this now (apologies for the delay). Some thoughts as I'm going through it:
|
Thanks for the feedback. I'm still interested in working on this. I'll update soon. |
This was originally brought up in #11962, but closed in favour of the more general #10100. However this commit doesn't address the broader theme of using alternate XDG vars for the default history path.
Here is the updated
sample_config.nu
documentation for the field:This is my first PR for Nushell, so I'm sure I'm missing some obvious things. One thing that even I don't particularly like is passing the
call.head
into the history modiule like thishistory.file_path(Some(call.head))
.User-Facing Changes
$env.history.path
value causesnu
startup to crash). I must have missed some defaults somewhere?Tests + Formatting
HistoryConfig.file_path()
?After Submitting