Closed flowchartsman closed 1 year ago
Thanks for the proposal!
A few things relevant:
chezmoi sets CHEZMOI=1
for the shell spawned by chezmoi cd
. You can use this to modify your prompt to show when you're in a subshell. There's some discussion in #2739.
The chezmoi: already in a chezmoi subshell
message is from #2821.
chezmoi shell
(terminal-style interactive readline interface)
This is effectively creating a new shell language inside chezmoi itself, and I don't want to do that. The user already has a favorite shell, and if you alias chezmoi
to cz
then only have to type three extra characters before each command and you can freely mix chezmoi commands with any other shell command.
chezmoi shellenv
/chezmoi complete
(templated config for sourcing)
chezmoi already has a chezmoi completion
command and if you installed chezmoi with a package manager then they should already be installed in the correct directory.
Prompt modification and aliases depend heavily on the user's preferences, so it's easier to let the user configure this themselves in their shell's dotfiles.
chezmoi admin
(interactive TUI)
This sounds complex. I think this would be better implemented as a wrapper around chezmoi. chezmoi already exposes all of its state through commands like chezmoi dump
and chezmoi state
.
Happy to hear more opinions!
Thanks for the response. That's valid criticism. The only minor thing I'd mention is that I don't think the readline environment would be creating a new shell language, so much as it would be an alternate way to process a limited set subcommands with arguments and completion. That could be complex from scratch, but the library actually makes it very easy. Otherwise you're right. I do agree that it's probably more trouble than it's worth.
Maybe it would be more useful to identify whether there are enough useful common tasks that currently require either chezmoi cd
or chezmoi git
that they merit new commands or subcommands. For example, the example given in the daily operations guide (which you might call update preview
) but modified to point at a temp directory might be worth that sort of porcelain, and I would definitely use it.
The commit workflow is another area that might benefit. I can see new users not wanting to faff around with git if they don't have to, and a baseline select some files -> comment -> push
wizard-sort of workflow would probably scratch the only itch I have.
This is a dotfiles manager, so it's already got a user base that is more inclined to enjoy bikeshedding on the VCS-centric parts of the workflow (and they should be able to if they want), but maybe that portion turns off other users. I can't speak for them, so I don't know if anyone would care. It's not a dealbreaker for me, but I would definitely use a more guided commit workflow if I could. I guess part of it is that Chezmoi is already fairly batteries-included for editing and secrets, I was expecting something similar for committing, but was unable to find it.
Of course, I also missed chezmoi completion
, so maybe it exists and I just missed that somehow. If that's the case, please close the issue and save me further shame!
A wrapper might be a good start. I note that you already include bubbletea, which is the direction I was consdering, so it might not be a huge lift to do a PR either, but that's only if it might be useful. I could mock up a workflow if you want to consider it further, otherwise I'll probably write a wrapper or even a superset application so I can be the lazy developer I aspire to be.
As usual, please feel free to WONTFIX this if so. No harm no foul.
Firstly, thank you for your excellently considered thoughts!
For example, the example given in the daily operations guide (which you might call
update preview
)
chezmoi update --dry-run --verbose
or, equally, chezmoi update -nv
should do this.
The commit workflow is another area that might benefit. I can see new users not wanting to faff around with git if they don't have to, and a baseline
select some files -> comment -> push
wizard-sort of workflow would probably scratch the only itch I have.
chezmoi has autoCommit
and autoPush
. This got recent updates in https://github.com/twpayne/chezmoi/issues/3023 that allow you prompt for the commit message if you want, or use a sensible default commit message if you don't.
I could mock up a workflow if you want to consider it further, otherwise I'll probably write a wrapper or even a superset application so I can be the lazy developer I aspire to be.
Please do mock up a workflow. I'll close this now but please do re-open.
This is an issue to gauge interest and feasibility based on an idea I had for an interesting feature, so feel free to close unceremoniously if it's totally out-of-scope.
Is your feature request related to a problem? Please describe.
This idea occurred to me after picking up chezmoi again and, after going through the quickstart, I found myself typing
chezmoi cd
again to check in some new files only to receive the messagechezmoi: already in a chezmoi subshell
. I then realized that I'd been in the "subshell" for who knows how long with no indication that it was "special". While this didn't really affect anything, it did mean that I needed to either manually navigate back to$HOME/.local/share/chezmoi
orexit
andchezmoi cd
again. A minor annoyance, but it got me thinking about thecd
command itself, why it was necessary, and what the alternatives might be.The given reason for the
cd
command in the user guide is that you kind of need to spawn a sub-shell if you want to change directories with a command. This is an unfortunate necessity, however the command does not attempt to run any shell-specific commands to differentiate the new "environment" --as you might see withvenv
,direnv
and the like. In fact, it doesn't even output a message indicating that a shell is being spawned that you might want toexit
from when you're done. As the user guide hints,chezmoi cd
is really just a workaround for functionality that can (and maybe should) be handled by an alias instead. This represents and opportunity for considering alternatives.Describe the solution you'd like
There are a few different options that might be interesting. Names are of course subject to change/discussion, and simply serve to distinguish the different options:
chezmoi shell
(terminal-style interactive readline interface)This command would start an interactive CLI mode using something like go-prompt and would serve as a sort of "basic default" for common tasks normally served with
chezmoi cd
. This avoids the need for the user to set up anything special to support a dedicated subshell for chezmoi, and could fall back to the same behavior aschezmoi cd
, provided there's config set for it.Supported commands could include checking in the repo, adding blocks of changes, etc.
chezmoi shellenv
/chezmoi complete
(templated config for sourcing)This command would output templated configuration for various shells that could be
source
d, similar to how features likekubectl completion
operate. It could provide something as basic as prompt modification and environment sourcing, or it could set up aliases as well as autocompletion based on the state of the repo and the database.chezmoi admin
(interactive TUI)This command would spawn a functional, but simple interactive TUI for administrative actions, and could provide a selection of basic statistics and views showing the status of managed files (diff/sync/etc).
Additional context
Given that I'm a relatively new (newly returning?) user, I haven't fully explored this proposal in terms of features and UX, and it might be off the mark, but since
chezmoi cd
is listed in the quickstart, I felt like it was a good opportunity to provide basic functionality and avoid confusion for new users. I'd appreciate feedback!